简体   繁体   English

fmdb fmresultset没有加载任何东西

[英]fmdb fmresultset not loading anything

some friends and me are developing a game in cocos2d :), and im using fmdb for some settings in it. 一些朋友和我正在开发一个cocos2d :)游戏,我正在使用fmdb进行一些设置。 Actually i have this code : 其实我有这个代码:


NSString *path = [[NSBundle mainBundle] pathForResource:@"myDB" ofType:@"sqlite"]; NSString * path = [[NSBundle mainBundle] pathForResource:@“myDB”ofType:@“sqlite”];

mainDB = [FMDatabase databaseWithPath:path]; mainDB = [FMDatabase databaseWithPath:path];

if ([mainDB open])
    NSLog(@"did open db");
else 
    NSLog(@"did not open db");

_stages = [[NSMutableArray alloc] init];

[mainDB open];

FMResultSet *FResult = [mainDB executeQuery:@"select * from stagesTable"];

NSLog(@"columns : %d",[FResult columnCount]);

if ([FResult next]) if([FResult next])
NSLog(@"have objects"); NSLog(@“有对象”);
else 其他
NSLog(@"dont have objects"); NSLog(@“没有对象”);

NSLog(@"with %d objects",[_stages count]);

[mainDB close];

But FResult is not storing anything, mainDB does open, but columns are 0 objects are 0 and it always says that it doesnt have any objects. 但是FResult没有存储任何东西,mainDB确实打开了,但是0列的对象是0,它总是说它没有任何对象。 What could be wrong? 可能有什么不对? Thanks :D ! 感谢:D !

Try setting logsErrors=YES; 尝试设置logsErrors=YES; on your mainDB and watch the output on the console. 在您的mainDB并在控制台上观察输出。

You never populate _stages so that will always have zero objects in it.. 你永远不会填充_stages,因此它总是会有零对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM