How to get integer values from iPhone SQLite data base normally we use following was for varchar or string but how can we get NSInteger values?
const char *sql = "select * from questions";
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {
while(sqlite3_step(selectstmt) == SQLITE_ROW) {
NSInteger primaryKey = sqlite3_column_int(selectstmt, 0);
DataController *coffeeObj = [[DataController alloc] initWithPrimaryKey:primaryKey];
coffeeObj.restaurantLocation = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 1)];
coffeeObj.foodQualityRating = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 2)];
restaurantlocation and foodquality rating or NSString I have survey id in Integer how can we fetch that from table.
If the surveyId field is the next column in the table after food quality you would use the following code:
The 3 at then end of the statement is the column index