开发者

I can not retrieve a value from my table

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);
}

It throws a开发者_StackOverflow社区n exception like below:

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

what is the problem with the indicated statement? I used sqlitemanager. I have 3 attributes in my table relatively id(integer), name(text), desc(text). Also, I have one row for example. I cannot retrieve the name.


You're calling the stringWithUTF8String: method on NSString, which returns an autoreleased string - so you don't need to alloc call too. The line should read:

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

Also, incidentally, your NSLog call on the last line isn't quite right - the format specifier should be %@, rather than just %, because you're putting in an NSString:

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜