我遇到的ABPeoplePickerNavigationController生成殭屍和凍結我的應用程序的麻煩,我嘗試了幾種方法來初始化,但好歹還是另一個似乎會隨機凍結我的應用程序:的ABPeoplePickerNavigationController凍結我的應用程序
if([appDelegate testInternetConnection]){
ABPeoplePickerNavigationController *picker =[[ABPeoplePickerNavigationController alloc] init];
[picker setPeoplePickerDelegate:self];
[self presentViewController:picker animated:YES completion:nil ];
}else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Internet Connection Error" message:@"This App needs internet in order to work, please make sure you are connected to a valid network" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil];
dispatch_async(dispatch_get_main_queue(), ^{
// Display/dismiss your alert
[alert show];
});
}
我不知道我做錯了什麼,但這是凍結我的應用程序outsite模擬器或當它沒有調試的設備。 任何想法爲什麼?
-Update
這裏是我使用的核心數據
#pragma mark Save data to Core Data Safely
-(void) saveData{
NSPersistentStoreCoordinator *mainThreadContextStoreCoordinator = [appDelegate persistentStoreCoordinator];
dispatch_queue_t request_queue = dispatch_queue_create("com.4Postcards.savingData", NULL);
dispatch_async(request_queue, ^{
// Create a new managed object context
// Set its persistent store coordinator
NSManagedObjectContext *newMoc = [[NSManagedObjectContext alloc] init];
[newMoc setPersistentStoreCoordinator:mainThreadContextStoreCoordinator];
// Register for context save changes notification
NSNotificationCenter *notify = [NSNotificationCenter defaultCenter];
[notify addObserver:self
selector:@selector(mergeChanges:)
name:NSManagedObjectContextDidSaveNotification
object:newMoc];
// Do the work
// Your method here
// Call save on context (this will send a save notification and call the method below)
NSError *error;
BOOL success = [newMoc save:&error];
if (!success)
NSLog(@"%@",error);
// Deal with error
});
}
- (void)mergeChanges:(NSNotification*)notification
{
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"Data Saved");
});
}
保存爲我說,現在當運行連接到它的Xcode不凍結的代碼,但斷開當它
你在你的應用程序使用coredata? – Saad 2014-09-22 22:04:58
爲什麼你需要互聯網來選擇聯繫人? – rmaddy 2014-09-22 22:05:16
您是否嘗試過使用調試器來查看您的應用「凍結」的位置? – rmaddy 2014-09-22 22:05:33