I\'m making an iOS App that need to show some images from a remote site (from an URL), and everytime the users enter to the screen that should show the image, the app get fr
Check out main.m in the FMDB distribution- it shows how to save and pull out a binary blob (using the safari icon as an example)".
- (NSData *)getCoverForMovie:(Movie *)movie
{
NSData *cover = nil;
FMDatabase *db = [FMDatabase databaseWithPath:databasePath];
[db open];
FMResultSet *results = [db executeQueryWithFormat:@"SELECT * FROM COVERS WHERE movie = %i", movie.movieID];
if([results next])
{
cover = [results dataForColumn:@"cover"];
}
return cover;
}
- (BOOL)saveCover:(NSData *)cover ForMovie:(Movie *)movie
{
BOOL result;
FMDatabase *db = [FMDatabase databaseWithPath:databasePath];
[db open];
result = [db executeUpdate:@"INSERT OR REPLACE INTO COVERS (movie, cover) VALUES (?,?)", movie.movieID, cover];
return result;
}
Thanks to @ccgus for his answer.