Reputation: 364
ABPersonViewController *personController = [[ABPersonViewController alloc] init];
personController.personViewDelegate = self;
ABRecordRef person = ABAddressBookGetPersonWithRecordID(personController.addressBook, [recordID intValue]);
personController.displayedPerson = person;
personController.allowsEditing = YES;
personController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back",nil) style:UIBarButtonItemStylePlain target:self action:@selector(returnFromPersonView)] ;
personController.navigationController.navigationBarHidden = NO;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:personController];
navController.navigationBar.tintColor=[UIColor colorWithRed:27/255.0 green:27/255.0 blue:29/255.0 alpha:1.0];
[self presentViewController:navController animated: YES completion:nil];
Getting crash in this line personController.displayedPerson = person; as [Not A Type retain]: message sent to deallocated instance
Upvotes: 2
Views: 318
Reputation: 1396
Try to get addressBook not from controller, but explicitly create it instead:
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &err);
ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook, [recordID intValue]);
Upvotes: 1