开发者

Possible FMDatabase/FMResultSet bug

开发者 https://www.devze.com 2023-03-07 14:02 出处:网络
Even though I rarely have problems with FMDatabase, I noticed some odd behavior today and was wondering if this is a bug or due to a mistake of my own.

Even though I rarely have problems with FMDatabase, I noticed some odd behavior today and was wondering if this is a bug or due to a mistake of my own.

NSString *query = [NSString stringWithFormat:@"SELECT * FROM TABLE_A WHERE modelId = %lu", modelId];
FMResultSet *resultSet = [db executeQuery:query];

while ([resultSetIPTCProperties next]) {
    NSLog(@"MODEL ID: %lu", [resultSetIPTCProperties intForColumn:@"stringId"]);
}

The odd thing is that this all works fine, but I wanted to play safe and precede the while loop with an if statement using [db hasAnotherRow], but this returns NO even when the result set does contain results.

When I log the resulting dictionary (using FMResultSet's resultDict method) to th开发者_StackOverflow中文版e console, I get a warning from FMResultSet saying "Warning: There seem to be no columns in this set." even though I can use them in my while loop.

Am I missing something here?


You have to call [resultSet next] before you can call [resultSet resultDict] otherwise the pointer in the result is before the first row. This is also why your loop works, but your check for hasAnotherRow does not.

0

精彩评论

暂无评论...
验证码 换一张
取 消