NSString *aDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
NSString *aImageUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
我想将
aImageUrl
读取为二进制。我怎样才能做到这一点? 最佳答案
如果要存储来自该URL的实际图像,则需要使用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]];