Apples iOS4- For the Developers

by Noc Team on June 29, 2010

Contributed by Asad Khan

Last week at Apples World Wide Developer Conference Steve Jobs unveiled iPhoneOS’s yearly major upgrade, introducing a plethora of new functionality. In this post we will try to touch the tip of an iceberg in terms of what iOS4 has to offer to the developers.

The first thing you’ll notice about iPhoneOS is that it has been renamed to iOS, because now it runs on iPads, iPhones & iPod touches & iOS is somewhat a generic name.

Below is the description of new features in the iOS from the developer’s point of view.


The first and foremost thing that catches the attention of every developer is the ability of iOS4 to multitask. Multitasking is not a new feature in mobile computing, Palm’s WebOS, Google’s Android & even Microsoft’s Windows Mobile have multi-tasking capabilities. Multitasking application’s lifecycle is a little different than the traditional application lifecycle that we were used to in Cocoa touch. Apples multitasking implementation is somewhat similar to that of Google’s on the Android platform. Which is in-fact not true multitasking just a mere illusion of it.

When a user wants to switch to another application the state of application is saved or frozen in the memory and when the user gets back to the application the state of application is restored giving an illusion that application was running all along.

When the application is inactive it is barred from any processing except if the application has registered as one of the follows

  • Location (GPS related)
  • Audio
  • VoIP (Voice over IP)

This is how application state is specified in the UIApplication.hheader file

typedefenum {




} UIApplicationState;

Illustrating that we have three application states on the iOS4.

  • Active
  • Inactive
  • In Background

When the application is launched we will receive the usual message from the app delegate

– (void)applicationDidFinishLaunching:(UIApplication *)application

didfinishLaunchingWithOptions(NSDictionary *)launchOptions

In addition to thiswe will now also receive this message

–    (void)applicationDidBecomeActive:(UIApplication *)application

When going to the background we will receive these messages

– (void)applicationWillResignActive:(UIApplication *)application

– (void)applicationDidEnterBackground:(UIApplication *)application

When in background there are no guarantees that the app will remain in the memory for the entire eternity. If there is a OOM(Out Of Memory) call the runtime will kill our application & free some memory.

When our application comes back to foreground these two methods will be called by the app delegate.

– (void)applicationWillEnterForeground:(UIApplication *)application

– (void)applicationDidBecomeActive:(UIApplication *)application

We can implement our logic in these two delegates; like connecting to the server again or whatever the logic of our application demands.

iOS4 also gives us the functionality to ask for a little more time for processing when the application is being suspended so that we can save state or finish the job for that matter before getting suspended. These are the two calls we can use to tailor our app to our requirements.

–    (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler: (void(^)(void))handler;

–    (void)endBackgroundTask:(UIBackgroundTaskIdentifier)identifier;*

*Notice the weird looking syntax (void(^)(void)), this is known as a block & is a recent addition to the C, C++, Objective C & objective C++ by Apple & is abundantly used in many Foundation classes so understanding it is very crucial, more on it later.

Local Notifications

A new feature in iOS4 is of local notification system, this feature somewhat mimics the Apples Push Notification System but is local to the device. Any application can register for notifications locally on the device & the device can then send periodic updates as specified or can change the application badge or do all of the stuff that was possible with Push Notification System. For more information on Local Notification be sure to check out the UILocalNotification.h header file.


UIAutomation is a new framework that Apple has introduced with the iOS4 SDK. Now you can write Javascript based scripts to automate user testing & check your application rigorously. You can run your scripts along with all the performance tracking systems included in the SDK like Instruments or Shark.

Event Kit

The Event Kit enables the developers to access the calendar of the user on the device, so that the developer can create, edit, remove & search events on the calendar locally or any online calendars users are using. Developers will also be able to record change notifications for the events on the calendar.


iAd is Apples advertising framework, developers can use iAds for loading & presenting ads. Apple also enables developers to respond to the events in ads. One plus point of iAd is that when you tap on the ad in the application, the application will not exit to show you the ad in Safari, you will remain in the application & you can close the ad anytime you want to. This is one big convenience when compared with other ad offering frameworks like Google’s Ad-Mob.

Game Center

Is a social networking gamming system something like OpenFeint. Now you can view achievements, compare them with your friends, view leader boards, find new games etc all of the stuff which you were able to do with OpenFeint is now possible with Game Center.

About The Author

“Asad Khan is the CEO & Co-Founder of Semantic Notion. He first started programming on his Commodore 64 & has never looked back since. He is a serial entrepreneur. His first successful tech start-up was at the age 16. Currently, he is leading a small start-up which specializes in intelligent web solutions.  “

{ 1 comment… read it below or add one }

Tehseen Abbas June 30, 2010 at 2:26 AM

nice…! very handy introduction to new APIs in IOS4. keep it up…!

Leave a Comment

Time limit is exhausted. Please reload CAPTCHA.

{ 1 trackback }

Previous post:

Next post: