This library is no longer maintained. In iOS 9.0+ and macOS 10.11+, use
CNContactVCardSerialization
instead.
vCardSerialization
encodes and decodes between vCard and AddressBook records, following the API conventions of Foundation's NSJSONSerialization
class.
@import AddressBookUI;
#import "vCardSerialization.h"
NSURL *URL = [[NSBundle mainBundle] URLForResource:@"contact" withExtension:@"vcf"];
NSData *data = [NSData dataWithContentsOfURL:URL];
ABPersonViewController *viewController = [[ABPersonViewController alloc] init];
viewController.displayedPerson = (__bridge ABRecordRef)[[vCardSerialization addressBookRecordsWithVCardData:data error:nil] firstObject];
ABPeoplePickerNavigationController *navigationController = [[ABPeoplePickerNavigationController alloc] initWithRootViewController:viewController];
[self.navigationController presentViewController:navigationController animated:YES completion:nil];
NSArray *records = ...;
NSData *data = [vCardSerialization vCardDataWithAddressBookRecords:records error:nil];
MIT
Mattt (@mattt)