I have a Addressbook in my App which gets filled from a website by json. If I add a new Person on my website the person get added to the app addressbook on the next launch. If I update a persons name on my website it works perfectly.. but if I add a new image to a existing person it still shows the old default image from Apple after the reload. If I compile it the picture appears. Is there a cache for addressbook pictures?
I tried the following:
BOOL imgBool = ABPersonHasImageData(aContact); -> false
and
ABPersonRemoveImageData(aContact, &anError); -> false because no picture in AB
I add a Persons picture like this:
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[[[self.profsInSection objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] bildUrl]]]];
NSData *picData = UIImageJPEGRepresentation(image, 0.9f);
[...]
ABPersonSetImageData(aContact, (CFDataRef)picData, nil);
There are no Errors, it just saves the last picture and ignores new pictures… 🙁 Any ideas?
Haven’t you forget to call saving function, after applying your changes in the address book?
UPDATE: so, as long as you’re using ABUnknownPersonViewController, I’ve tried the following code by myself and it’s working both on the simulator & device
The issue I’ve met when was testing this code, was my mistype in image name, so the
UIImageinstance was nil andNSDatawas empty. AndABPersonSetImageDatagave no error on this. So, double check yourUIImageinstance is not nil.