- (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];
}