I have created a custom property in AddressBook named "Qref". I can check it's there using [ABPerson properties]
, and it's always there for any test app I write.
By the way, you can't remove custom properties, because [ABPerson removeProperties]
hasn't been implemented. Let me know if it ever is, because I need to remove one whose name I mistyped.
I set a property value with this code.
ABPerson *p = <person chosen from a PeoplePicker>;
NSError *e;
if (![p setValue: aString forProperty:@"Qref" error:&e]) {
[NSAlert alertWithError:e]runModal;
}
(I have never seen the alert yet, but sometimes get a heap of error messages in the console.)
At this point I can navigate away from the person in the PeoplePicker and return to find the value correctly set.
If I check [[ABAddressBook sharedAddressBook] hasUnsavedChanges]
the result is NO, so clearly changing a custom property value doesn't count as a change, so I force a save by inserting dummy person (please suggest a better way), then executing
[[ABAddressBook sharedAddressBook] save];
The dummy person appears immediately in AddressBook if it is running, so something's right. But when I close my app and run it again, I find the values I set have gone. (MacOSX-Lion)