Proper checking of nil sqlite text column
问题 I have an sqlite string column that is assigned to a string. I need to make sure it isn't nil before assigning. I'm doing this: char *isNil = sqlite3_column_text(selectstmt, 2); if(isNil != nil){ myName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 2)];} which gives the warning: warning: initialization discards qualifiers from pointer target type What is the proper way to do it? 回答1: You're getting the warning as you're ignoring the const. The API is defined: const