Let me explain what i want to do first. In native Iphone in the Recents tab if you click on a contact not found in any addressbook you have an option to "Add to Existing Contact"
After clicking on "Add to Existing Contact", a picker shows up and you make a selection. Afterwards it brings you to a ABPersonViewController
automatically and allows you to edit or save the new contact:
I am trying to recreate this but having some issues. In my version, After I create the UnknownPersonViewController and the end user presses "Add to Existing Contact" a picker shows up and allows for selecting from the addressbook similar to native Iphone. But after making a selection the name gets automatically added to the addressbook and no personViewController appears to give the user a choice to add the contact or not. Even if i could just get it to not auto write to the addressbook after making a selection i could just have it show a personviewcontroller in edit mode right away.
So my issue is why is it automatically updating the addressbook after making a selection? Im pushing the ABUnknownpersonviewcontroller onto a UITableviewController navigationcontroller. and im testing on a physical device with iOS 6.01 Here is some code:
ABRecordRef person = ABPersonCreate ();
ABMutableMultiValueRef multiValue = ABMultiValueCreateMutable(kABStringPropertyType);
ABMultiValueAddValueAndLabel(multiValue, call.number, kABPersonPhoneMainLabel,
NULL);
ABRecordSetValue(person, kABPersonPhoneProperty, multiValue, error);
if(multiValue) CFRelease(multiValue);
ABUnknownPersonViewController *unknownCtrl = [[ABUnknownPersonViewController alloc] init];
unknownCtrl.displayedPerson = person; //this has a phone number with "main" label
unknownCtrl.allowsActions = YES;
unknownCtrl.allowsAddingToAddressBook = YES;
unknownCtrl.editing=NO;
unknownCtrl.unknownPersonViewDelegate = self;
// unknownCtrl.addressBook=ABAddressBookCreate(); // I tried setting addressbook to nil and object
unknownCtrl.addressBook=nil;
[self setTitle:call.type forUIViewController:unknownCtrl];
[self.navigationController pushViewController:unknownCtrl animated:YES];
note: i have a similar problem to this post : http://forums.macrumors.com/archive/index.php/t-1023140.html
and perhaps https://discussions.apple.com/thread/1682620?start=0&tstart=0
UPDATE: it seems if i put the kABPersonPhoneMainLabel from the person, then it does not write the phone number to the contact. Aftewards what i did was in didResolveToPerson delegate i call the personviewcontroller in edit mode. This simulates the native behavior. This may answer my own question, thanks everyone.