Created
March 31, 2013 07:44
-
-
Save jquave/5279904 to your computer and use it in GitHub Desktop.
This file contains 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
NSMutableArray *abEmailAddresses = [NSMutableArray array]; | |
NSMutableArray *abPhoneNumbers = [NSMutableArray array]; | |
ABAddressBookRef addressBook = ABAddressBookCreate(); | |
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(addressBook); | |
for (CFIndex i = 0; i < CFArrayGetCount(people); ++i) { | |
ABRecordRef aRecord = CFArrayGetValueAtIndex(people, i); | |
// phone numbers | |
ABMutableMultiValueRef phones = ABRecordCopyValue(aRecord, kABPersonPhoneProperty); | |
for (CFIndex j = 0; j < ABMultiValueGetCount(phones); j++) { | |
CFStringRef phoneNumber = ABMultiValueCopyValueAtIndex(phones, j); | |
[abPhoneNumbers addObject:[NSString stringWithFormat:@"%@", phoneNumber]]; | |
CFRelease(phoneNumber); | |
} | |
CFRelease(phones); | |
// emails | |
ABMutableMultiValueRef emails = ABRecordCopyValue(aRecord, kABPersonEmailProperty); | |
for (CFIndex j = 0; j < ABMultiValueGetCount(emails); j++) { | |
CFStringRef emailAddress = ABMultiValueCopyValueAtIndex(emails, j); | |
[abEmailAddresses addObject:[NSString stringWithFormat:@"%@", emailAddress]]; | |
CFRelease(emailAddress); | |
} | |
CFRelease(emails); | |
} | |
CFRelease(people); | |
CFRelease(addressBook); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment