开发者

How to save data before app enters multasking

Im trying to find a way开发者_如何学Go to save data before my app enters multitasking, i know how to save data, but i dont know what method to use to save it before the app enters multitasking.

-(void)applicationDidEnterBackground:(UIApplication *)application{

this one? because i have everything set up to save, but it doesn't seem to be saving it, and im positive that its the multitasking part because it works on the ios 3 simulator. Do i have to save it in the delegate?

Thanks, Jacob

EDIT: On the IOS 3 one i have it saving data in the

- (void)applicationWillTerminate:(UIApplication *)application {


Yes Jacob, You have to save it in the application delegate of your app.

The method -(void)applicationWillResignActive:(UIApplication *)application gets called when the device enters standby mode or when the app is switched to background. So the saving part you can add to this method .

Also to make the app save data for iOS versions < 4.0 , add the saving code to applicationWillTerminate: also.


You should use the method what is the method Apple recommends

-(void)applicationDidEnterBackground:(UIApplication *)application

but you can also use

- (void)applicationWillResignActive:(UIApplication *)application

which is the method that is called instead of

- (void)applicationWillTerminate:(UIApplication *)application


Take a look at this Delegate method:

-(void)applicationWillResignActive:(UIApplication *)application

This allows you to react when the application becomes inactive. See the Docs for more information.

Happy coding :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜