以下代码:
-(NSArray *)getContentsWithContextTypes:(NSArray *)contextTypes
contextData:(NSArray *)contextData
{
__block NSString *query = @"SELECT * FROM Texts_original1 WHERE ";
[contextData enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
NSString *attributeName = [self.contextTypeToDBQueryTexts
objectForKey:contextTypes[idx]];
query = [query stringByAppendingFormat:@"%@ = \"%@\"", attributeName, obj];
if(idx != contextData.count - 1)
{
query = [query stringByAppendingString:@" AND "];
}
}];
[self.db open];
FMResultSet *results = [self.db executeQuery:query];
NSMutableArray *array = [NSMutableArray array];
while([results next])
{
Content *content = [[TextualContent alloc] initWithResults:results];
[array addObject:content];
}
[self.db close];
return array;
}
当我运行它时生成以下错误:
调用 sqlite3_step 时出错(21:内存不足)rs
它发生在循环的一半。应该有 33 个结果。17 之后我得到那个错误并且循环退出。有任何想法吗?谢谢。