Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mraheel

macrumors regular
Original poster
Apr 18, 2009
136
0
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

macrumors member
Jun 25, 2010
43
0
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

macrumors newbie
Jun 19, 2010
25
0
UK
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

macrumors regular
Original poster
Apr 18, 2009
136
0
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

macrumors member
Jun 25, 2010
43
0
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

macrumors newbie
Jun 19, 2010
25
0
UK
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

macrumors regular
Original poster
Apr 18, 2009
136
0
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:

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

macrumors regular
Original poster
Apr 18, 2009
136
0
okay, got the answer to that, apparently u have to synchronize the userdefaults.. cuz that isnt happening in appDidEnterBackground

[defaults synchronize]; did the trick
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.