开发者

What does this mean? Initialization discards qualifiers from pointer target type

开发者 https://www.devze.com 2023-02-23 04:06 出处:网络
I\'m trying to load text from sqlite database in detailed view and I\'m getting this error. Initialization discards qualifiers from pointer target type.

I'm trying to load text from sqlite database in detailed view and I'm getting this error.

Initialization discards qualifiers from pointer target type.

What does this mean? and how can I fix it. Help please. Here is my code.

-(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 showin开发者_运维问答g 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;
}

Thanks.


sqlite3_column_text is declared to return a const unsigned char *, and you are assigning it to a variable of type char *. This loses the const qualifier, so the compiler is warning you of that fact.


this will also work:

char* foo = (char *)sqlite3_column_text(statement, 1);
NSString* Foo = (foo) ? [NSString stringWithUTF8String:foo] : @"";
0

精彩评论

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