было бы проще, если вы используете SQLite и fmdb .Ниже приведен код для хранения и получения изображений с использованием fmdb.
// let's read in an image from safari's app bundle.
NSData *safariCompass = [NSData dataWithContentsOfFile:@"/Applications/Safari.app/Contents/Resources/compass.icns"];
if (safariCompass) {
[db executeUpdate:@"insert into blobTable (a, b) values (?,?)", @"safari's compass", safariCompass];
rs = [db executeQuery:@"select b from blobTable where a = ?", @"safari's compass"];
if ([rs next]) {
safariCompass = [rs dataForColumn:@"b"];
[safariCompass writeToFile:@"/tmp/compass.icns" atomically:NO];
// let's look at our fancy image that we just wrote out..
system("/usr/bin/open /tmp/compass.icns");
// ye shall read the header for this function, or suffer the consequences.
safariCompass = [rs dataNoCopyForColumn:@"b"];
[safariCompass writeToFile:@"/tmp/compass_data_no_copy.icns" atomically:NO];
system("/usr/bin/open /tmp/compass_data_no_copy.icns");
}
else {
NSLog(@"Could not select image.");
}
[rs close];
}
else {
NSLog(@"Can't find compass image..");
}
Код взят непосредственно из репозитория fmdb git.