// DBに接続-(id)dbConnect:(NSString*)dbName{NSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);NSString*dir=[pathsobjectAtIndex:0];FMDatabase*db=[FMDatabasedatabaseWithPath:[dirstringByAppendingPathComponent:dbName]];returndb;}// テーブルの作成-(void)createTable:(NSString*)dbNametableName:(NSString*)tableName{FMDatabase*db=[selfdbConnect:dbName];NSString*sql=[[NSStringalloc]initWithFormat:@"create table if not exists %@ (id INTEGER PRIMARY KEY, title TEXT, imgData TEXT)",tableName];[dbopen];[dbexecuteUpdate:sql];[dbclose];}
-(UIImage)getImgData:(NSString*)dbNametableName:(NSString*)tableName{NSData*imgData;FMDatabase*db=[selfdbConnect:dbName];NSString*select=[[NSStringalloc]initWithFormat:@"select * from %@ order by id desc limit 1",table_name];[dbopen];FMResultSet*rs=[dbexecuteQuery:select];while([rsnext]){NSString*imgString=[rsstringForColumn:@"imgData"];imgData=[[NSDataalloc]initWithBase64EncodedString:imgStringoptions:NSDataBase64DecodingIgnoreUnknownCharacters];}UIImage*img=[UIImagealloc]initWithData:imgData];]}