Using this code you can retrieve the pictures of contact stored in your AddressBook!
ABAddressBookRef addressBook = ABAddressBookCreate();
NSMutableArray *people = [[[(NSArray*) ABAddressBookCopyArrayOfAllPeople(addressBook) autorelease] mutableCopy] autorelease];
[people sortUsingFunction:(int (*)(id, id, void *) ) ABPersonComparePeopleByName context:(void*)ABPersonGetSortOrdering()];
UIImage* image;
for (int i = 0; i < [people count]; i++)
{
ABRecordRef person = [people objectAtIndex:i];
if(ABPersonHasImageData(person)){
image = [UIImage imageWithData:(NSData *)ABPersonCopyImageData(person)];
}else{
image = [UIImage imageNamed:@"contact_image.gif"];
}
}
Popularity: 6% [?]



How can we display address book images in our application
yep you can do that. the code i already written get all the images from contact list , you just need to stored those images in some mutable array and used it anywhere you likes
I have more than 2k contacts to read form addressbook, but the reading code crashes ( low memory) after reading 2k records. Application have no leak in contacts reading code, i checked with leak application.
Amit,
the leak is in the line:
image = [UIImage imageWithData:(NSData *)ABPersonCopyImageData(person)];which instead should read something like:
CFDataRef imageData = ABPersonCopyImageData(person)];
image = [UIImage imageWithData:(NSData *)imageData];
CFRelease(imageData);
Hey,
Where/how exactly do we have to execute this code ?