Search code examples
iphoneioscocos2d-iphonefmdb

fmdb fmresultset not loading anything


some friends and me are developing a game in cocos2d :), and im using fmdb for some settings in it. Actually i have this code :


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

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])
NSLog(@"have objects");
else
NSLog(@"dont have objects");

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. What could be wrong? Thanks :D !


Solution

  • Try setting logsErrors=YES; on your mainDBand watch the output on the console.

    You never populate _stages so that will always have zero objects in it..