New in iPhone Development? You can now follow this blog on google readers or subscribe for email or Twitter!
If my tutorial help you then please donate, so that i continue writing free tutorials for every developer/programmer/freelancer
If my tutorial help you then please donate, so that i continue writing free tutorials for every developer/programmer/freelancer
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% [?]
Related posts:
- iPhone Tutorial for Retrieving Contact information from AddressBook Introduction In this tutorial I will explain how you can...
- iPhone Tutorial for Creating a Splash Screen Introduction: Some people asked me about creating a splash screen...
- iPhone SDK Tutorial – {Part 4} Tips for UITableView Design [Add Header, Footer, Background Images & change Design] UITableView Tutorial: {Part 4} This tutorial will explain, how you...
- iPhone Programming Tutorial {Part 7}: Adding Pictures into your table using Interface builder Creating iPhone Application: Introduction: I am going to write series...
- Tutorial/Tips (Sorting & Filtering): Filter NSMutableArray and Sorting NSMutableArray by Ascending or Objects or Specified key or Key Value or by NSNumber Sorting objects held in an NSMutableArray is a pretty common...
[...] April 4, 2009 at 2:25 PM (iPhone) (AddressBook, Contact, iPhone) Moved to Adeem.me [...]
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);