这是我的代码,错误也可见:
在 Mozzila Firefox 的 SQLite 管理器中 - 所有查询工作正常,这意味着数据库是正确的
也许有人可以指出我的代码有什么问题?
编辑:
我的代码:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
NSString *path = [docsPath stringByAppendingPathComponent:@"stories_db.sqlite"];
FMDatabase *db = [FMDatabase databaseWithPath:path];
//[db open];
if ([db open]==true)
{
FMResultSet *resultsFavorite = [db executeQuery:@"SELECT count(*) from favorites"];
while ([resultsFavorite next])
{
Pasaka *pasaka = [[Pasaka alloc]init];
pasaka.title = [resultsFavorite stringForColumn:@"story_name"];
pasaka.image = [resultsFavorite stringForColumn:@"image_path"];
pasaka.movie = [resultsFavorite stringForColumn:@"video_path"];
[favoriteMovieList addObject:pasaka];
}
}
编辑2:
当我做这个查询时:
FMResultSet *results = [db executeQuery:@"SELECT count(*) FROM sqlite_master"];
它没有显示任何错误。