objective-cabpersonviewcontroller

Prompt ABPersonViewController with uniqueID


I want to load a existing contact using the address book view controller using only the uniqueID of the contact. How can a "person" record be defined using only the uniqueID?

ABPersonViewController *view = [[ABPersonViewController alloc] init];

view.personViewDelegate = self;
view.displayedPerson = person; 

[self.navigationController pushViewController:view animated:YES];

Solution

  • Not sure if this it what you are asking, but you create a person for ABPersonViewController like this.

    CFErrorRef err;
    ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &err);
    ABRecordRef person = (ABRecordRef)ABAddressBookGetPersonWithRecordID(addressBook, [contact.recordId intValue]);
    
    personVC.displayedPerson = person;