Created
February 24, 2011 17:03
-
-
Save fernyb/842453 to your computer and use it in GitHub Desktop.
Creating a new person with AddressBook.framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ABPerson * newPerson = [[ABPerson alloc] init]; | |
[newPerson setValue:@"John" forProperty:kABFirstNameProperty]; | |
[newPerson setValue:@"Doe" forProperty:kABLastNameProperty]; | |
ABMutableMultiValue * values = [[ABMutableMultiValue alloc] init]; | |
[values addValue:@"[email protected]" withLabel:kABOtherLabel]; | |
[newPerson setValue:values forProperty:kABEmailProperty]; | |
[[ABAddressBook sharedAddressBook] addRecord:newPerson]; | |
if ( [[ABAddressBook sharedAddressBook] save] ) { | |
NSString * addrbookUrl = [NSString stringWithFormat:@"addressbook://%@?edit", [newPerson uniqueId]]; | |
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:addrbookUrl]]; | |
} | |
[values release]; | |
[newPerson release]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment