How to retrieve image from sqlite database in iPhone App
In my iPhone App I want to retrieve image from (stored in ) sqlite database table in "BLOB" datafield.
For that I am storing my image in NSData using code
NSData *imageData = UIImagePNGRepresentation(image);
and I am also able to retrieve image from NSData -> UIImage by code
self.img1=[UIImage imageWithData:imageData];
And displaying Image into imageView by
imageView2.image=img1;
I am storing image (in NSData form) into sqlite database table column (of BLOB Datatype) successfully.
I am using below code to retrieve image from database
NSData *imageData2 = [[arraySelect objectAtIndex:0] valueForKey:@"image_column"];
NSLog(@"imagedata2 in retrive :: %@",imageData2);
in 开发者_开发问答NSLOG i am getting the same data stored in database column (in blob datatype "NSData form" )
Now I am retrieving image by (while debugging it crashes here and showing meaasge EXE_BAD_ACCESS)
self.img3=[UIImage imageWithData:imageData2];
imageview3.image=img3;
But I am not getting that image in imageView. I checked all outlets but they are ok.
So please Help and Suggest what I should do to get image in imageView from database.
Thanks.
@Prerak i think this will help you something..and solve your problem http://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/
精彩评论