A late-binding, message-based, object-oriented language that is a strict superset of C and is primarily used for programming on Apple's Mac OS X and iOS platforms. Objective-C can also be used on other platforms that support gcc or clang.
0
votes
1answer
17 views
UITableView 'hidden' section causing more memory allocations every time on pull to refresh
I'd like to see how to improve this code. I have a UITableView that I'm 'hiding' a section when the user taps on that section's header. I thought this was a pretty cool implementation I came up with, ...
4
votes
1answer
31 views
How can I improve this AVCaptureMetadataOutputObjects wrapper?
With iOS7, Apple introduced AVCaptureMetadataOutputObjects, which is used for scanning barcodes. If you check out the web for how to scan barcodes in iOS, almost everyone is talking about ZBarSDK. ...
3
votes
1answer
25 views
How can I condense several IBAction methods in a class with a delegate?
I have the following class:
MyProtocolClass.h
#import <Foundation/Foundation.h>
@protocol MyExampleProtocol <NSObject>
@required
- (void)someRequiredMethod:(NSInteger)someValue;
@end
...
0
votes
0answers
35 views
iOs. Simplest UITableView app - a table of questions. Can't figure it out. Help. [closed]
Don't want to tell you how much time I spend trying to solve this apparently simple task.
After finishing iOs Big Nerd Ranch guide, I decide to create a simple app to strengthen my knowledge of ...
4
votes
1answer
54 views
UITableView cellForRowAtIndexPath
I'd like to see how I can improve this code, as I know it's bad practice to have cell reuse identifiers like this, but I could not find any other way to keep the cells that contain images from calling ...
-1
votes
1answer
69 views
App for playing and recording video
I'm making an app using AVFoundation that is essentially a photo booth with a view to play a video and a view to display and record video. Right now I'm implementing all of the code in the ...
9
votes
1answer
95 views
Tic Tac Toe implementation in Objective-C
First off, here's the code:
main.m
#import <Foundation/Foundation.h>
#import "PSBoard.h"
#import "PSPlayer.h"
#import "PSInputHandler.h"
int main(int argc, const char * argv[]) {
...
7
votes
2answers
268 views
Game with tile map - Sprite-Kit
I'm a novice programmer learning Objective-C in my spare time. I would greatly appreciate any help or advice with my code. I want to follow best practices whenever possible. I know that I am ...
5
votes
1answer
49 views
Optimize a synchronization with remote web service
I am writing a method to synchronize the local Core Data entities with a remote web service (in this case Parse.com).
To update changed or created objects, I fetch all where the "updatedAt" date ...
5
votes
2answers
111 views
Elegant way to split an NSArray into NSDictionary of array
I need to split one NSArray into NSDictionary. Every key in NSDictionary will contain an NSArray with the object with the same value.
i.e. I have an array with 1000 customers and I want create an ...
5
votes
1answer
94 views
How to make this recursive function thread-safe?
I have an array that I want to enumerate using blocks concurrently. However, I'm having trouble making this thread safe. I am new to using blocks and locks, so I am hoping someone may be able to push ...
4
votes
1answer
53 views
Assigning initial value via getter or viewDidLoad
I've been coding in a vacuum for several years and am trying to get up to speed on best practices, in anticipation of my eventual return to employment. I'm hoping this is the best forum in which to ...
6
votes
3answers
111 views
HTTP scraper not clean and straightforwardly coded?
A job application of mine has been declined because the test project I submitted was not coded in a clean and straightforward way.
Fine, but that's all the feedback I got. Since I like to ...
1
vote
2answers
86 views
How can I remove this for-loop in this competitive FizzBuzz code?
I'v written this code snippet that's part of a code competition.
I want to do the trick without the for-loop, or simply find a way to optimize this code for speed.
for ( i=1; i<=N; i++ )
...
5
votes
1answer
72 views
Presenting modal dialogs from XIB in Cocoa: best/shortest pattern?
Below is my typical WindowController module for presenting a modal dialog (could be settings, asking username/password, etc) loaded from a XIB. It seems a bit too complex for something like this. Any ...
1
vote
2answers
106 views
UIGraphicsImageContext Memory Spike - Reducing Footprint
I have a UIImage Category for iOS Objective-C which tints an image based on a given UIColor value. You can take a look at the method below:
- (UIImage *)tintImageWithTint:(UIColor *)color ...
2
votes
1answer
63 views
Pi to the Nth Digit
I'm trying to teach myself Objective-C/Cocoa for eventual iPhone development but I figured I would start with a terminal app. It takes a user input, strips everything but numerics, then displays PI to ...
3
votes
0answers
139 views
Canonical Implementation of a Subclass of NSOperation
I would like to develop a kind of template or canonical implementation for a concurrent subclass of NSOperation.
Requirements:
Thread safe API.
start shall only start the task once, otherwise it ...
3
votes
2answers
147 views
Multiple serial URL requests in Objective-C / iOS
I want to check the existence of various API endpoints by doing serial URL request. If the first one fails, I want to try the second one, if the second fails I want to try the third one, etc.
Here is ...
1
vote
1answer
39 views
cocoa change whether file is executable
This is a cocoa app that adds a right click menu option to change whether a file is executable. It works by executing the system command chmod on each of the files. But I want to know if there is a ...
4
votes
1answer
133 views
iOS / Objective-C Basics
Coming from Java & Android development and Objective-C still is a bit strange to me, but I just went in head first and started writing code. Before I started getting really far into it, I just ...
3
votes
1answer
106 views
applicationDidBecomeActive: Am I causing a memory leak?
in an ios app I´m calling this function everytime the app gets opened in the applicationDidBecomeActive: function. I´m using ARC. My concern is it could create a memory leak because it´s creating new ...
1
vote
0answers
62 views
Sample design Oauth2.0 flow [on hold]
I have the following code that I hope developers will use.
[LKOauth showLogin: self data: data
success: ^(NSString * code) {
NSLog(@"%@", code);
}
...
1
vote
1answer
175 views
A better way to handle web services in an iOS app?
I'm building an iOS app that uses web services extensively. I've built classes that handle the requests. However since there are a lot of web service request - I need to find out how to detect which ...
1
vote
1answer
489 views
I subclassed AFNetworking to handle POST / GET requested - doing it wrong?
So I am pretty new to iOS development - I'm writing an app the uses web services, pretty extensively. With that in mind, I decided to use AFNetworking 2.0 and subclass AFHTTPSessionManager.
I ...
2
votes
2answers
151 views
I need code review on using singleton to access local database
As I get to some performance issues in my app and find that I use database access in a bad way.
So I decided to move to singleton pattern.
I need someone to review this code and confirm me that I made ...
4
votes
2answers
511 views
iOS: Code review of MasterViewController
I plan on including this work in a portfolio.
Question: Will this code get me hired or laughed at?
More Specifically:
How would you rate the general complexity of the code?
How bad does the code ...
1
vote
1answer
136 views
iOS App ViewController Refactoring Guidance
My question is: How can I most effectively refactor the code in these 2 ViewControllers. I'm familiar with subclassing in objective-c and have used it extensively else where with NSObjects and ...
2
votes
1answer
163 views
Reviewing C function which captures the screen
I have created a function in C on OSX in Xcode which captures the screen, adds the mouse pointer to the image, rescales the image to fit a certain width X height requirement, and puts the rescaled ...
1
vote
1answer
379 views
Asynchronous networking IOS API calls
+ (void) makeRequestToEndPoint:(NSString *) endpoint values:(NSMutableDictionary *) params onCompletion:(SDKCompletionBlock) responseHandler
{
NSString * urlString = [self ...
3
votes
1answer
63 views
Is there a better way to make sure a variable is initialized when using blocks?
I have a method to provide an NSManagedObjectContext using UIManagedDocument. I need to ensure that the context did initialize before I return, so I added an infinite while loop at the end of the ...
0
votes
0answers
184 views
Created a BST for Objective-C, Looking for some feedback
I put together a Custom Linked List class in hopes to be used for a Talent/Skill Tree for a game, that allows for inserting nodes with NSMutableDictionary for Skills and Requirements along with a ...
1
vote
1answer
118 views
AutoreleasePool NSString Automatic Reference Counting
I have some doubt about how NSString is released in ARC Mode.
I would like to know if have something i can do to release a nsstring when i want in arc mode.
Take a look at this code:
__block ...
2
votes
1answer
54 views
Property getter implementation
I always see something like this:
- (NSMutableArray*)items {
if (_items == nil)
_items = [NSMutableArray array];
return _items;
}
Recently I wrote:
- (NSMutableArray*)items {
...
2
votes
3answers
190 views
Is there a better way of making an NSString with many argument values?
I have a form that I'm turning into a string value for an email, but the string value that I turn it into seems very complicated, plus I believe this way takes up a lot of memory and is somewhat slow ...
2
votes
2answers
361 views
Is this a correct way to write a convenience constructor?
I was reading more about the instancetype on Stack Overflow and now my question is:
For every convenience constructor that I write, do I need to have the corresponding one using init?
For example:
...
2
votes
1answer
169 views
Pulling Objects & Values From Arbitrarily Nested JSON
I got tired of stringing together objectAtIndex: and objectForKey: and hoping nothing fails along the way. I parse a lot of JSON from sources like the Google Directions API and it was cluttering my ...
0
votes
3answers
224 views
Objective-C class for placing UI elements based on screen size
I'm always programmatically creating and laying out UI elements in multiple ViewControllers and I've wanted an easy way to get relevant Screen information (sizes/points) globally using a helper class. ...
0
votes
0answers
323 views
SDWebImage - Fetch more images
What I am looking to do is, apart from setImageWithURL method of SDWebImage, load other images from the array of URL's.
So, in the completion block of setImageWithURL, I call a method ...
1
vote
1answer
61 views
Is this proper code for removing a CCSprite under certain conditions?
This is a "answer" to my own question over at stackoverflow, head over there to see what I am trying to accomplish. ...
3
votes
1answer
25 views
Creating an expanding CCSprite cluster
I am creating an "explosion" of circle sprites from the character with this code, and I was wondering if there is a more effective way to do such things, because this just seems too stupid.
(This is ...
2
votes
1answer
499 views
How can I improve below Objective-C code to tint an image?
I have an image which is a black ring:
In my view, I need to display it as a white ring. So, to tint the image, I have written the below method:
- (UIImage *)getRingImage
{
UIImage *ringImage ...
2
votes
1answer
107 views
using C scope syntax for code organization purposes
Would you ever use curly braces for making your code more organized and readable? for instance I could have:
- (void)methodName {
...
// action 1
{
...
}
...
}
Where ...
2
votes
1answer
118 views
Class design patterns: how to design reusable classes?
I have two classes DigBackground and DigParallaxBackgroundLayer (a parallax background is a image consisting of several images that move at different scroll speeds, for games etc.). My idea was to ...
4
votes
1answer
104 views
Simple yet efficient integer-to-object dictionaries?
Sometimes I need an NSDictionary-like object that maps a few integers (non-negative) to objects. At first glance, NSMutableArray is great for this, provided that the indexes aren't too high so I came ...
2
votes
1answer
58 views
A structure and helper functions for working with polar coordinates
Cross posting from Stack Overflow (not sure how to more correctly cross-post).
This started simple, as most things do...
I just wanted a little structure to hold polar coordinates for a totally minor ...
2
votes
2answers
318 views
iOS/Objective-C “if” best practice
I've got this code that I found in a project and I'm wondering how can it be done better:
- (void) setAlpha:(float)alpha {
if (self.superview.tag == noDisableVerticalScrollTag) {
if ...
3
votes
1answer
313 views
Logic question in a card matching game controller
I have a card matching game with a model of:
Card
Deck
PlayingCard
PlayingCardDeck
And another model called CardMatchingGame.
Now, I had a task to add a button to the view for new game, which ...
4
votes
1answer
111 views
Is there anything I can improve in this view controller implementation?
I'm using both Core Data and NSFetchedResultsController. Is there anything I can improve on? Thanks.
//
// RoutineTableViewController.m
// App
//
// Created by Me on 3/21/11.
// Copyright 2011 ...
2
votes
1answer
48 views
Creating a Playlist program
Exercise:
Define three new classes, called Song, Playlist, and
MusicCollection. A Song object will contain information about a particular song, such as its title, artist, album, and playing ...