I try to fetch imageData after refetching CNContact
using unifiedContactWithIdentifier:keysToFetch:error:
and CNContactImageDataKey
in Objective-C.
I'm using Xcode 7.0 building on iPhone 6 Plus with iOS 9.0.2.
In runtime I always have the same exception CNPropertyNotFetchedException
even refetching contact and checking imageData
calling imageDataAvailable
.
Here is the code:
if([currentNativeContact isKeyAvailable:CNContactImageDataKey] &&
currentNativeContact.imageDataAvailable) {
previewImage = [UIImage imageWithData:currentNativeContact.thumbnailImageData];
} else {
NSError *error;
currentNativeContact = [self.contactsStore unifiedContactWithIdentifier:currentNativeContact.identifier keysToFetch:@[CNContactImageDataKey] error:&error];
if(!error && currentNativeContact.imageDataAvailable)
previewImage = [UIImage imageWithData:currentNativeContact.thumbnailImageData];
}
You need to add CNContactImageDataAvailableKey
, CNContactImageDataKey
and CNContactThumbnailImageDataKey
keys to the keysToFetch
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With