PDA

View Full Version : Multitasking for ios4 but remaining compatible with 3.x




mraheel
Jul 8, 2010, 02:29 PM
Perhaps this is the most widely asked/answered question everywhere.. i couldnt figure out this one thing..

To enable multitasking, We HAVE TO SET THE BASE SDK 4.0 in project settings. that does the job alright...

but after that, does it remain compatible with 3.x?.. its only those 4 methods in appdelegate that were added... will they be ignored in 3.x? and whats the way to test it???



bweberapps
Jul 8, 2010, 10:40 PM
This been answered a few times in here... Set the base SDK to 4.0, then further down there is setting for target OS, set that to 3.0.

DemonJim
Jul 9, 2010, 12:04 PM
but after that, does it remain compatible with 3.x?.. its only those 4 methods in appdelegate that were added... will they be ignored in 3.x? and whats the way to test it???

Yes correct, when running on 3.x hardware it won't use the new 4.0 delegate functions. You must still provide the applicationWillTerminate etc. functions for these cases.

Best way to test is as always try it on actual hardware (eg keep an old iPod touch or an iPad on 3.x for this reason).

mraheel
Jul 9, 2010, 05:29 PM
Thanks for the help guys..

Yea, I changed the Deployment Target to 3.0 and tested it fine in the simulator.. I recently upgraded my itouch to ios4, before the app was working just fine on ios 3.0.

I just have to add some code to DidEnterBackground delegate function. (applicationWillTerminate will do the job in 3.x).

However, in Distribution (FINAL Compile before app submission), I should choose BASE SDK 4.0, obviously, but what should the the Deployment target?

bweberapps
Jul 10, 2010, 12:52 PM
Thanks for the help guys..

Yea, I changed the Deployment Target to 3.0 and tested it fine in the simulator.. I recently upgraded my itouch to ios4, before the app was working just fine on ios 3.0.

I just have to add some code to DidEnterBackground delegate function. (applicationWillTerminate will do the job in 3.x).

However, in Distribution (FINAL Compile before app submission), I should choose BASE SDK 4.0, obviously, but what should the the Deployment target?

I would leave the base SDK as 4.0 and the target OS as 3.0. This will give 4.0 users the new features, but make your minimum OS requirement 3.0 so users with older software can still download it.

DemonJim
Jul 10, 2010, 03:23 PM
If you're supporting 3.x then ensure you test it on actual 3.x hardware - the simulator is not an emulator. You risk customers getting crashes (eg by calling a 4.0 API) which will only result in 1 star ratings, ie not good!

mraheel
Jul 10, 2010, 04:11 PM
Yes, ur right.. will test it on 3.x hardware.

Im gonna hijack this topic to something a little relevant..
I've been trying to save state of the application by writing to NSUserDefaults.

Looking at the WWDC videos, They suggested that we do all our save settings routine in appDidEnterBackground method.. cause potentially it could be the last method before exit. and ApplicationWillTerminate isnt called at all if the user just deletes the app from multitasking menu.

It doesnt seem to work for me..

appDidEnterBackground has the following code:

if(bookmarkArray.count > 0)
[[NSUserDefaults standardUserDefaults] setObject:bookmarkArray forKey:@"bookmarks"];
else
[[NSUserDefaults standardUserDefaults] setObject:nil forKey:@"bookmarks"];
[self.mainController saveOnTerminate]; //this also writes to NSUserDefaults

Everything seems to work well in 3.x

Has there been anything different with regard to NSUserDefaults in 4.0?

mraheel
Jul 10, 2010, 04:21 PM
okay, got the answer to that, apparently u have to synchronize the userdefaults.. cuz that isnt happening in appDidEnterBackground

[defaults synchronize]; did the trick