NSString *aDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
NSString *aImageUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
我想将aImageUrl
视为二进制文件。我怎么能这样做?
答案 0 :(得分:2)
如果要存储该网址的实际图片,则需要使用BLOB(二进制大对象)。
//Storage
UIImage *image = ...; //Retrieve image from URL
NSData *imageData = UIImagePNGRepresentation(image);
sqlite3_bind_blob(compiledStatement, 1, [imageData bytes], [imageData length], NULL);
//Retrieval
const void *data = sqlite3_column_blob(compiledStatement, 1);
int length = sqlite3_column_bytes(compiledStatement, 1);
UIImage *retrieved = [UIImage imageWithData:
[NSData dataWithBytes:data length:length]];