In My iPhone App,
I am converting my image in to NSData 开发者_开发知识库format and storing it into sqlite database Table in dataType="BLOB",
But, I am retriving that image (stored in NSData format) into NSArray Format from database,
The Problem is I am not able to convert NSArray to NSData ( Which would Help me to get my image back into NSData format )
Please Help and Suggest, Thanks
Your requirement is so odd.
- you can store image in local file system with the file name in sqlite
- if you really want images store in sqlite, you can every image in sqlite separately rather than archive images in NSArray than convert to NSData
Use NSKeyedArchiver How to convert NSArray to NSData?
UIImage *imgData = [UIImage imageWithData:[yourArray objectAtIndex:theIndex]];
for multiple images in one array you can loop it
like
for (int i = 0;i<[yourArray count];i++) {
UIImage *img = [UIImage imageWithData:[yourArray objectAtIndex:i];
//do something here with each image
// for example, add it to an ImageView
}
P.S. if theres only one image, its index is 0 hope this helps
精彩评论