Pitfalls to avoid in iOS programming

After creating your application using iOS suite you may think that this is the best thing that’s happened since bubble gum hit jackpot. One of the great things about the iOS (iPhone/iPad) world is the geographic spread of users. Everyone around the world is in love with Apple, from the US to China and everywhere in between. This means a huge audience for your game, jackpot is not it. True, it may sound like the last burst of the bubble gum. There are so many loose ends to tie before you make your application a block buster for the consumer. By pointing out flaws will make your entry to the iPhone books easier and smarter.

Implementing a cute Tetris type clone – Honey Pot, is possible in iOS programming. New ideas flow in and the aim was to learn iOS programming, become fabulously wealthy and retire to a life of luxury. We suggest you to try out every piece of functionality that Apple offers, just to see how it works. Being into that for years, we can say, Apple has built localization into the core of the iOS experience.  When done properly, the user sets their preferred language, and then all the applications magically convert to the language. (Note: If you have not implemented localization in the app, it will not convert.) It’s designed to be simple and works well.  They’ve also given the ability to add different languages to iTunes as well, so people when shopping for apps see descriptions in their own language. Great stuff, but how does it work?

iOS in short

The iOS family includes the iPhone, the iPad, and the iPod touch. These devices offer innovative mobile platforms that are a joy to program. They are the founding members of Apple’s family of pocket-based computing devices. Apple’s iOS doesn’t install on non-Apple hardware and has 700K + iOS applications to support. It came from OS X on which Apple computers run. There are 4 different abstraction layers:

i. Core OS layer
ii. Core Services layer
iii. Media layer
iv. Cocoa Touch layer.

Currently, iOS 6.1 is the latest. System partition requires 1-1.5 GB of device (flash) memory, out of which, around 800 MB (depending on the model) is used by iOS. Apple’s most popular app has been Siri, an intelligent personal assistant and navigator who works on iSpoken commands and makes the device (iPhone – 4S/5, iPod Touch – 5th generation, iPad – Mini/3rd& 4th generations) work for the user.

The Memory pitfalls

Process of allocating memory should use explicit memory management through code that might be loaded into either a garbage-collection or non-garbage-collection process. iOS memory mistakes are common with beginners, especially deallocation methods in each of the classes. Automatic Reference Counting helps but you still need to learn how retain/release works in order to avoid certain pitfalls. iOS does not provide garbage collection and even with ARC you are still responsible for managing your memory. This makes iOS hesitate with memory management; so it’s better avoided. The most  crucial aspect involves calling super dealloc method before dealloc  to avoid memory leak is where allocated memory is not freed, even though it is never used again. Leaks cause your application to use ever-increasing amounts of memory and subsequent system crash. Excess use of NSLog Statements slows down an app’s performance. The NSLog statements work best when debugging the app, anymore and they will hog the memory.

#define NSLog(…)

The iOS debugging commands are there because they work! But new iOS developers don’t seem to have much faith on them. With NSDebugEnabled or MallocStackLogging (environment variables), identifying causes become easier. Incorporating iOS debugging commands within the app development process shall help avoid memory crashes a great deal.

4 more to go:

i. Consistency in naming (and casing too): You can’t present Customer Number as custN or custID at random, as it makes them different pieces of data instead of being the same thing. If it’s custN, then keep it that way throughout.

ii. Date & time: 12’0 clock is neither AM nor PM; it’s either noon or midnight. Keep it 12:00 and 00:00 in a 24-hour format or just 12:00 in the other.

iii. UI style: iOS is based on the concept of direct manipulation, using multi-touch gestures. Interface control elements consist of sliders, switches, and buttons. A number of designing for iOS isn’t much different than designing for the web. In fact, it’s a bit easier since you’ll be working on a smaller screen with specific access points. Practicing with the native iPhone graphics is the easiest path for newbie designers. Included is a small list of bells and whistles native to the iOS interface. These are the buttons and toolbars you see most commonly around the App Store. And Webdesigner.com provides the basic knowledge in fireworks and Photoshop.

iv. Overdependence on code completion tools: Vim is fairly well and we often use it for iOS development. Enter clang_complete. It’s a plugin for Vim that uses clang to perform code completion. Clang is also used by XCode for the same reason. Eventually it will replace the gcc and llvm compiler. Once downloaded and installed the script will not work for any objective-c code for iOS. It is necessary to install by running xcode build in verbose mode to see what commands were passed through to the compiler to come up with the command line arguments to configure clang_complete with. Keeping a vigil saves a lot of hassles afterwards.

To lighten your load

Web Service Error when accessing Print Lab function.

The best check is to go for the for error messages. This is the best way to tap a problem. If the Web app is not working due to a faulty JavaScript, following the error message in the Javascript console press F12 in IE/Chrome; for Firefox, using Firebug will put you back on the track. Firebug enhances console usage without having to check if window console exists; the script will fail silently. Opening the console leads to window console existing; this allows the script to continue execution. An alternative lies in installing LogMeIn on any iPhone, iPod touch, or iPad running iOS 4.3 or higher.

Thus, learning to develop on the iOS using objective-C is going to give you some experience with Objective-C and OO in general. LogMeIn helps control the work computer from your Mobile Device. Faulty JavaScript bugs can then be assembled and removed from the host computer by any enthusiastic programmer.



Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s