One way to do this is to check during startup if there is a new field in the table. You can use the following SQLite command to retrieve all fields from a table
PRAGMA table_info(table-name);
If the field you are looking for is not in the result set, do ALTER TABLE table-name ADD COLUMN column-name column-type to update the table.
You can use this method to scroll through the fields of a table.
- (BOOL)getFields { const char *sql = "PRAGMA table_info(myTable)"; sqlite3_stmt *stmt; if (sqlite3_prepare_v2(db, sql, -1, &stmt, NULL) != SQLITE_OK) { return NO; } while(sqlite3_step(stmt) == SQLITE_ROW) { NSString *fieldName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt, 1)]; NSLog(@"%@", fieldName); } return YES; }
Hope this helps
source share