NSString *query = [[NSString alloc] initWithFormat:@"SELECT * FROM objects ", catIdS];
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
char *nameChar = sqlite3_column_text(statement, 1);
NSString *title = [[NSString alloc] initWithUTF8String:nameChar];
}
sqlite3_finalize(statement);
}
语义问题"使用const char类型的表达式初始化char *会丢弃限定符"在char *nameChar = sqlite3_column_text(statement, 1)
如果将char *nameChar
更改为char *nameChar
语义问题"将unsigned char *发送到const char *"类型的参数;将指针转换为具有不同符号的整数类型
答案 0 :(得分:8)
施放它应该可以解决您的问题。
char *nameChar = (char *)sqlite3_column_text(statement, 1);
或
const unsigned char *nameChar = sqlite3_column_text(statement, 1);
请查看方法的签名
SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
答案 1 :(得分:1)
使用它像这样,它可能会有所帮助
NSString *title = [[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 1)];