Hi, I am trying to set an image for an contact that is store in my iPhone. I used follwing code snipt - (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
UIImage *image = [UIImage imageNamed:@"icon.png"];
NSData *data=UIImagePNGRepresentation(image);
CFDataRef dr = CFDataCreate(NULL, [data bytes], [data length]);
ABAddressBookRef iPhoneAddressBook = ABAddressBookCreate(); CFErrorRef erf=NULL;
if (ABPersonSetImageData(person, dr, nil))
{
NSLog(@"successfully set image");
}
else
{
NSLog(@"not successfully set image");
}
if( ABAddressBookSave(iPhoneAddressBook, &erf) )
{
NSLog(@"save %s",erf);
}
else {
NSLog(@"Not success");
}
CFRelease(dr);
CFRelease(iPhoneAddressBook); [self dismissModalViewControllerAnimated:YES];
return NO;
}
every thing is working but the image of the contact does not change. plz help!