Created
January 20, 2011 08:39
-
-
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.
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
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