Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can do this in the following manner. After you add the object just call the <code>ReloadData</code> UITableView Method and it will reload the table again. So there is no need To restart the application again.</p> <pre><code> static sqlite3 *addStmt = nil; - (void) add_Place:(Place *)PlaceObj { NSLog(@"Super add called"); //Add it to the database. [PlaceObj addPlace]; //Add it to the coffee array. [PlacesArray addObject:PlaceObj]; [TableView ReloadData]; } - (void) addPlace { NSLog(@"addplace called"); if(addStmt == nil) { NSLog(@"inside addstmt"); const char *sql = "INSERT INTO places_table ( PlaceName, PlaceAddress) Values (?,?)"; if(sqlite3_prepare_v2(database, sql, -1, &amp;addStmt, NULL) != SQLITE_OK) { NSLog(@"error inside if loop"); NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database)); } } NSLog(@"outside if Loop") ; sqlite3_bind_text(addStmt, 1, [PlaceName UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(addStmt, 2, [PlaceAddress UTF8String], -1, SQLITE_TRANSIENT); if(SQLITE_DONE != sqlite3_step(addStmt)) { NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));; } // NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database)); else { //SQLite provides a method to get the last primary key inserted by using sqlite3_last_insert_rowid PlaceID = sqlite3_last_insert_rowid(database); NSLog(@"sqlite3_last_insert_rowid") ; } //Reset the add statement. sqlite3_reset(addStmt); } </code></pre> <p>Cheers</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload