Skip to content

Instantly share code, notes, and snippets.

@amudi
Created January 20, 2011 08:39
Show Gist options
  • Save amudi/787587 to your computer and use it in GitHub Desktop.
Save amudi/787587 to your computer and use it in GitHub Desktop.
[iOS] Get address book thumbnail if the method is available. Should weakly link the framework.
ABAddressBookRef addressBook = ABAddressBookCreate();
NSArray *allAddressBookPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
for (int i = 0; i < [allAddressBookPeople count]; ++i) {
ABRecordRef record = [allAddressBookPeople objectAtIndex:i];
NSData *imageData = nil;
if (ABPersonCopyImageDataWithFormat != NULL) {
imageData = (NSData *)ABPersonCopyImageDataWithFormat(record, kABPersonImageFormatThumbnail);
} else {
imageData = (NSData *)ABPersonCopyImageData(record);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment