We’re rewarding the question askers & reputations are being recalculated! Read more.
21

According to the iOS Device Compatibility Reference, the iPhone 3GS was the only iOS 6-capable device to lack a front camera. The same document states that your application can declare the requirement for a front-facing camera by setting the UIRequiredDeviceCapabilities key such that front-facing-camera is true. That way, you can safely strip out the ...


21

The current range of iOS devices that support 7.0+ don't include any devices that lack a front-facing camera. I also agree with you that it is unlikely that Apple will release any future devices without the front-facing camera (though not impossible). Even if they do, however, you could and should specify that your app requires this hardware in the ...


17

In this case, your indentation makes the code drift over to the right so does make the code difficult to read so does need some changes. First I would note that a lot of code is repeated and also as noted a switch after converting the condition to an int is possible. However in this case your code is effectively doing multiple lookups so I would look at ...


16

Your algorithm tries to find the largest factors first. This is ineffective because you have to test each possible factor whether it is a prime number or not. It is much more effective to start with the smallest factor. If you divide the number by each factor found this way then you will get only prime factors, and the prime testing function isPrime() ...


15

for(int i = 1; i <= 19; i++) { i = ( i%2 == 0 && i!=19 ) ? i+1 : i; [waitFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"lev_wait2%04d.png", i]]]; } Holy Toledo. First of all, if you must update the iterator within a for loop, let's leave the update statement empty: ...


14

In GitHub for Mac, we use a combination of AFNetworking and our own Mantle and ReactiveCocoa frameworks for API requests. AFNetworking makes it trivial to create your own "network manager" type object as a subclass of AFHTTPClient. We enqueue requests on it, ask them to hand back a certain kind of MTLModel subclass, and then subscribe to the resulting ...


13

I will update this post over the weekend as I go through your question more and come up with some examples to iterate over my points, but I thought for now, I'd answer some of the easier questions. Question 1. I'm not sure and cannot remember (I will try to find out). At the end of the day, you might consider implementing this with a GUI. If you're using ...


13

Because this question is so, so large, I won't get into all the specifics of everything I see. I will point out some things, and provide some examples from one file or another, and as you work through my answer, you should work through your project to find all the other instances of an example I point out. I will start with a simple answer to the topic ...


13

I'm just a beginner myself but I feel like I can point out a few things in this code. First, I would add some white space at the top of the file here: #import "ESFlashingErrorBar.h" #import "ESThemeManager.h" @implementation ESFlashingErrorBar #define kNumOfPoints 7 int lastFlash; Instead I would do this for increased readability: #import "...


12

I observe that: Only one function has any comments There is a fair amount of commented out code The variable names aren't very helpful Somethings are just misspelled: getSyrvey, rectoreWorm The code seems to mix various things together (drawing/particle system/database access) There is also this nugget: for(int i = 1; i <= 19; i++) { i = ( i%...


12

Assuming the values under the id keys always match properties of currentAppswitches. If you can change currentAppswitches's class to accept an NSNumber object rather than a BOOL you have some convenient options. If currentAppswitches is KVO compliant you could write: for (NSDictionary *item in switchesArray) { id value = [item objectForKey:@"value"]; ...


11

You're right. There is a simpler way. First of all, instead of giving every interactive element its own method, let's give them all the same method. - (IBAction)buttonPressed:(id)sender; If they're not all buttons, a different method name is in line, but for this example, I'll assume them all to be buttons. Now then, whether you're creating these UI ...


11

-(id) initWithWorldSizeForCharacter:(CGSize)worldSize andStartingFloor:(int)startingFloor; It's slightly better to use instancetype as the return type here rather than id. What we're actually returning (here) is a DTEnemyMovement object, but explicitly listing this as the return type is problems when subclassing because we're returning the super type ...


11

Using a property for the boolean attribute is fine. Properties have many advantages: they encapsulate an objects value (i.e. the actual implementation is hidden from the outside, it need not be an instance variable), they are public (instance variables are by default not visible from other classes), they can be observed (via Key-Value Observing). In the ...


11

The problem of formatting an ordinal number is a general one that applies to more than just 31 days of a month. You also have repetition of much of the string @"Today is the %lu?? day of the month". Therefore, I suggest defining a separate function for handling this problem. Taking inspiration from NSNumberFormatter and 'th' 'st' 'nd' 'rd' (ordinal) ...


10

In iOS 4 and later you are encouraged to use animation blocks. [UIView animateWithDuration: 0.5f delay: 0.08f options: UIViewAnimationCurveEaseIn animations: ^{ self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); } completion: ^(BOOL finished)...


10

Instance Variables and Properties Understanding exactly what a @property is is absolutely crucial to being a good Objective-C programmer. Here's my crash course. An instance variable is just that. An instance variable. It's pretty straight forward. It's just a variable in that can be accessed by all the methods in your class. And if it's a public ...


9

This is the the way singletons are usually implemented in apple's code samples. + (ItemsManager *)sharedInstance { static ItemsManager *sharedInstance = nil; static dispatch_once_t once; /* Doing the allocation inside dispatch_once queue ensures the code will run only once for the lifetime of the app. */ dispatch_once(&once, ^{ ...


9

I don't like that you've implemented logic in Main. Move the logic into a FizzBuzz method and call that from Main. (Even though it seems really silly for such a simple program, it's not best practice to have it there.) I'm also not a fan of hard coding 15 as the "FizzBuzz" case. What if we decide that Fizz should be 2 and Buzz should be 5? Now 15 as your ...


9

@property You declare properties in the header file, but you don't actually use them as anything more than instance variables, which suggests you may not quite understand their full power. An Objective-C property is three things. An instance variable A setter A getter When you write @property int numerator;, you have created all three of these things. ...


9

The correct way to check for success or failure of Cocoa (Touch) methods is documented in "Handling Error Objects Returned From Methods" in the "Error Handling Programming Guide": Important: Success or failure is indicated by the return value of the method. Although Cocoa methods that indirectly return error objects in the Cocoa error domain are ...


9

The problem with any sort of timer in which each "tick" is a measurement from the previous "tick" is that in software, these "ticks" are not guaranteed to be exact. This means that if your first tick is off by a tenth of a second, every remaining tick will be off by that amount or more. Your second tick is scheduled based on your first tick. This means ...


9

If you need to check if a certain method exists you can also check if the object supports it via respondsToSelector: like this: if ([object respondsToSelector:@selector(openURL:options:completionHandler:)]) { [object openURL:...options:...completionHandler:...]; } else { [object openURL:...]; } I think this approach is more flexible than checking ...


8

Winston's answer points out some improvements to your algorithm. There are other ways in which we can slightly improve the speed of this. In Objective-C, for loops (and while and do...while) loops are handled one iteration at a time and the exit condition is checked on each iteration of the loop. Meanwhile, a forin loop is handled in batches. When we're ...


8

Put your image mapping in a property list: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>113</key> <dict> <key>condition</key> <string>Sun.png</string> ...


8

When you have something like this in your code: - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } You can simply delete all 5 of these lines. The only reason to include the the stub for - (void)didReceiveMemoryWarning is if you're actually going to add code to the method. int ...


8

Now, given that basically all Objective-C is written to make use of Cocoa frameworks, and we're talking about programs to run on OSX or iOS, we have to discuss Apple. Apple is pretty consistent when their method naming conventions, and their way of doing things. So any conversation about Objective-C standard practice would be incomplete without a very ...


8

A slightly better option that takes a little more effort up front but saves a lot of time in the long run, and makes the code more readable (and the obfuscated word harder to crack) would be to follow this pattern... First, create an NSString class category and fill that category with a readonly property for every character. @interface NSString (Obfuscater)...


8

@property (retain) id chessdelegate; There are several things wrong with this line. retain - While this technically still is a property attribute, it has been replaced by strong. It does the exact same thing as strong, but strong is the vastly preferred term here. retain or strong are both wrong here anyway. Any delegate property should ALWAYS be weak or ...


Only top voted, non community-wiki answers of a minimum length are eligible