
I installed iOS 4 on my iPhone 3GS the day it was available. It runs great and the new features are extremely useful. I’ve turned my 10 pages of apps into 3 pages using folders! I’ve been–as well as many others–waiting for multitasking for apps like Pandora and it’s finally here! I am now waiting for Rhapsody to provide an update with multitasking.
As is with every iPhone OS update, I need to install the new SDK to actually do any work. The update to iPhone SDK 4.0 wasn’t without a few hiccups! We are almost done with the rather hefty Propaganda Lander update and it will run just fine on iOS 4.
iPhone SDK 4.0 assumes every app that you develop will utilize multitasking. As of now, we don’t find much use for multitasking in our games. Propaganda Lander won’t have multitasking. When you close it, it will clear itself out of memory and won’t sit there hogging system resources.
While playing around with the new SDK, I have seen Propaganda Lander operate in the background. I’ve switched from Propaganda Lander to Safari and back. It’s kinda cool. Although, using any other resource intensive application will cause iOS to shut down Propaganda Lander anyway so it’s not particularly useful in that sense.
Implementing Multitasking
I had some difficulty trying to figure out how to opt out of multitasking! I followed the instructions Apple provides in their manual but, it just didn’t work–it had mostly to do with my shallow understanding of Xcode. Developers switching to iPhone SDK 4.0 will realize that their games will have an error upon exiting because it assumes the app is going to run in the background and you haven’t handled for it.
You can either handle for it using these two functions:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[glView stopAnimation];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[glView startAnimation];
}
They should reside in your AppDelegate and in this case we are stopping our animations when the app enters the background and restarts our drawing when the app enters the foreground. You are not allowed to make any GL calls while in the background.
That’s a quick way to implement background support although there are lot of other things that you need to account for depending on what your app is doing. Apple has a guide for that.
Opting Out
The other alternative is to simply opt out of running in the background. Apple has a guide for that as well but, it’s not exactly as they describe! Maybe I’m just not as Mac-savy–and I’m not–but, I followed their instructions and added the key/value pair to Propaganda Lander’s Info.plist and nothing happened.
With a little help from Nik–a Mac veteran if you will–we figured out that you can’t simply write YES as a string in the key/value pair. You need to right click in the value box and change the Value Type to a Boolean. This is seemingly obvious except I didn’t know you could do that. I’m from PC-land and we don’t use plists.
So if you are like me and can’t seem to figure out why Apple’s instructions aren’t working, this is what you need to do. It is also possible that I’m the only person developing for iPhone that didn’t know that in which case, hope you had a good laugh!