首页 > 移动平台 > 详细

iOS 后台退出app时不执行applicationWillTerminate的临时解决方法

时间:2015-11-23 21:41:15      阅读:2178      评论:0      收藏:0      [点我收藏+]
- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    //实现一个可以后台运行几分钟的权限, 当用户在后台强制退出程序时就会走applicationWillTerminate 了.
    [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:nil];
    
}

 

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    NSString * AddressBookIndex = @"AddressBook_index";
    NSString * AddressBookDataArray = @"AddressBook_dataArray";
    NSString * AddressBookPhonePerson = @"AddressBook_Person";
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:AddressBookIndex];
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:AddressBookDataArray];
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:AddressBookPhonePerson];
    
}

 

iOS 后台退出app时不执行applicationWillTerminate的临时解决方法

原文:http://www.cnblogs.com/levy/p/4989630.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!