I am having trouble in converting NSData
to a UIImage
.
I capture an image from the device camera, and convert this image into NSData
to store it in SQLite using the BLOB data type.
The image data is successfully stored in the DB, but when I retrieve my image data, the application crashes.
I use this code:
NSData *tempData = [[NSData alloc] init];
tempData = [[arr_img objectAtIndex:indexPath.row] valueForKey:@"Image"];
UIImage *img = [[UIImage alloc] initWithData:tempData];
and get this error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString bytes]: unrecognized selector sent to instance 0x5f8c000'
What am I doing wrong?
alloc/init
to write overtempData
immediately? – Sergey Kalinichenko