views:

24

answers:

2

I'm using the address book framework to get all the contacts from my iphone phonebook.

Is there any way to get (and use) the contact picture?

Thank you.

Thomas

A: 

Yes you can. You need to check out the Address Book documentation for iOS and especially look at the ABPerson reference.

http://developer.apple.com/library/ios/documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html#//apple_ref/doc/uid/TP40007210

Wim Haanstra
thank you, unfortunately I don't really understand that documentation... :/ I have been there, I can get everything else from the contacts. :)
Thomas Clayson
found the ABPersonCopyImageData() function :) Seems to work if you map it to (NSData *) and use imageWithData: thank you. :)
Thomas Clayson
A: 

Yes you can... this code from the Address Book API

array = [peoplePicker selectedRecords]; 
NSAssert([array count] == 1, @"Picker returned multiple selected records"); 

ABPerson *person = [array objectAtIndex:0];
personImage = [[NSImage alloc] initWithData:[person imageData]]; 
personFirstName = [person valueForProperty:kABFirstNameProperty], personLastName = [person valueForProperty:kABLastNameProperty];
/* ...do something with the image and name... */ [personImage release];
KiranThorat
Is ABPerson available as an Objective-C class on iOS? I thought it was just on the Mac.
Brad Larson
I do remember I used it.. Not positive ... I think have sample code.. I will try to post once I get home.
KiranThorat