Search
Goodies

Social Networks
Designs I Like
« Memory management and viewDidUnload | Main | Poll - What is your expectations on iOS4 multitasking? »
Wednesday
Jun232010

Preparing my application for iOS4

Since iOS4 came out, I had a chance to try out Ultimate Password Manager on my 3GS and see how things were going. Well, Things did not go as expected. The application was crashing at launch, 2 or 3 seconds after startup to be exact. This was telling me that the application initialization sequence was going pretty far before encountering a problem. This was the time to fire up Xcode 3.2.3 and try a quick Build and Run. Here is what was in need of attention in order to be fixed.


Interface Builder - XIB warning and errors

The easiest part was the Interface Builder seems a little bit more capricious regarding segmented controls:


All of my segmented controls had the same problem. A quick test showed me that this was a warning and the segmented control with one segment were still working like a charm. I'm using segmented controls with one segment to simulate a great looking button with tint and gradient. Eventually I'll replace them with my own.

The next thing Interface Builder was complaining about was the default colour of UITableView. 

So, for each UITableView, I had to change the background colour as follow:

From:
To:

Many of the warning were gone. The weird thing is that those errors were flagged even if my target was iOS 3.1.2 and Base SDK was iOS 4.0. If I'm building against Base SDK 4, why generate about errors related to iOS 3? Another dev mentioned the exact same problem via its twitter feed. Maybe a bug.

Objective-C runtime errors

It seems that the Objective-C runtime under iOS is more strict regarding the usage of integer stored in an NSDictionary as NSNumber... In order to read them back, if they were stored in NSNumber, they need to be read with objectForKey:, followed by a integerValue message sent to the NSNumber object. Here is an example:

The following line in iOS 3.1.3 would return an integer without any issue but crashes in iOS4:

expiresInDays = [[appDelegate.passwordSafe objectAtIndex:index] integerForKey:kpwdEntryValidForDays];

The fix was to rewrite this as:

expiresInDays = [[[appDelegate.passwordSafe objectAtIndex:index] objectForKey:kpwdEntryValidForDays] integerValue];

Lost of small fix had to be applied in many places...

Multitasking - fast switching
My application was not ready to support iOS4's fast application switching. Having the application sitting in the task switching bar in a "suspended" stated for a long time without receiving any event to quit was creating a problem: if the user selected to "kill" the application from the task switcher, it would lose all of the application's data modifications. For a quick fix, I had to use the new UIKit key: UIApplicationExitsOnSuspend set to True in the info.plist. This way, when the user switches to another tasks, Ultimate Password Manager is really quitting and saving its data as on iOS 3.1.3. In a future version of my application, I will make sure that fast application switching is fully supported by responding to the right delegate method sent to the UIApplication object.

Version 2.2.1 of Ultimate Password Manager that fixes of those problems has been submitted to Apple for approval. I'm still waiting for them to let it go. My users upgrading their device to iOS4 are complaining. Not good. The waiting game is in full swing.

Reader Comments (1)

We are involved in the mobile development industry, specialising in developing apps for the iPhone, iPad, Android and Blackberry. For more information, please look at our link: http://bit.ly/cMasiI

June 24, 2010 at 6:41 | Unregistered Commentermoonlight42

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>