我正在尝试从详细视图中的sqlite数据库加载文本,但出现此错误。

初始化从指针目标类型中丢弃限定符。

这是什么意思?以及如何解决。请帮助。这是我的代码。

-(void) hydrateDetailViewData {
        if (isDetailViewHydrated) return;

        if (detailStmt == nil) {
                const char *sql = "Select ClubAddress from clubNames Where clubID = ?";
                 if (sqlite3_prepare_v2(database, sql, -1, &detailStmt, NULL) !=SQLITE_OK)
                         NSAssert1(0, @"Error while creating detail view statment. '%s'", sqlite3_errmsg(database));
                 }
        sqlite3_bind_int(detailStmt, 1, clubID);

        if (SQLITE_DONE != sqlite3_step(detailStmt)) {
                char *db_text = sqlite3_column_text(detailStmt, 2); //error showing here
                NSString *address = [NSString stringWithUTF8String: db_text];
                self.ClubAddress = address;
        }
        else
                NSAssert1(0, @"Error while getting the address of club. '%s'", sqlite3_errmsg(database));
        sqlite3_reset(detailStmt);

        isDetailViewHydrated = YES;
}


谢谢。

最佳答案

声明sqlite3_column_text返回一个const unsigned char *,并且您将其分配给char *类型的变量。这失去了const限定符,因此编译器会警告您该事实。

10-08 07:32