I am fetching an image from contact and storing it like:
NSData *contactImageData = (__bridge NSData *)ABPersonCopyImageDataWithFormat(person, kABPersonImageFormatThumbnail);
UIImage *img = [UIImage imageWithData:contactImageData];
NSLog(@"%@",img); //returns like '<UIImage: 0x7fc740460260>'
[contactInfoDict setObject:img forKey:@"image"]; //contactInfoDict is a NSDictionary
Now again I'm setting the image like:
UIImage *image = [UIImage imageWithCGImage:(__bridge CGImageRef)([contactInfoDict objectForKey:@"image"])];
cell.profileImg.image = image;
But nothing happening. there is no image at all. What I did wrong?
Update
I also tried:
NSData *contactImageData = (__bridge NSData *)ABPersonCopyImageDataWithFormat(person, kABPersonImageFormatThumbnail);
[contactInfoDict setObject:contactImageData forKey:@"image"];
fetching it like:
NSString *str = [contactInfoDict objectForKey:@"image"];
NSData* data=[str dataUsingEncoding:NSUTF8StringEncoding];
UIImage *image = [UIImage imageWithData:data];
cell.profileImg.image = image;
But not working. After setting NSData to image image returns nil.