我无法从我的表中检索值

时间:2010-04-20 11:03:30

标签: objective-c sqlite

while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
    // Read the data from the result row
    NSLog(@"WHILE IS OK");

    //// THIS NEXT STATEMENT ////
    NSString *araci = [[NSString alloc] stringWithUTF8String:(char *)
            sqlite3_column_text(compiledStatement, 1)];**

    [deneme addObject:araci];

    NSLog(@"Data read");
    NSLog(@"wow: %",araci);
}

它抛出了如下的异常:

[NSPlaceholderString stringWithUTF8String:]: unrecognized selector sent to instance 0x3d0c0c0'

指示声明有什么问题?我用过sqlitemanager。我的表中有3个属性相对id(integer), name(text), desc(text)。另外,我有一行例如。我找不到名字。

1 个答案:

答案 0 :(得分:0)

你正在NSString上调用stringWithUTF8String:方法,该方法返回一个自动释放的字符串 - 所以你也不需要分配调用。该行应为:

NSString *araci = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];

另外,顺便提一句,你在最后一行的NSLog调用不太正确 - format specifier应该是%@,而不仅仅是%,因为你输入了一个NSString:

NSLog(@"wow: %@",araci);