Note that there are some explanatory texts on larger screens.

plurals
  1. POsqlite database resets on each compile and run
    primarykey
    data
    text
    <p>I have built up a basic database application in which user can insert records onto a table and app displays them on a TableView.</p> <p>Everything is working as it is supposed to be. For example, the new records do display even if we kill the app from app switcher and relaunch it from the springboard.</p> <p>BUT every time I build and run using Xcode, the database just goes to default records! The new records are just not there.</p> <p>Is it normal?... but what if I want to test my app for new records? Any fix?</p> <p>BTW, JFYI, below is the code I use to make editable DB.</p> <pre><code>-(NSString *)createEditableDatabase{ // Check if DB already exists BOOL success; NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *error; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [paths objectAtIndex:0]; NSString *writableDB = [documentsDir stringByAppendingPathComponent:@"Database.db"]; success = [fileManager fileExistsAtPath:writableDB]; //The editable DB already exists if (success) { return writableDB; } //The editable DB does not exist //Copy the default DB into App's Doc Dir. NSString *defaultPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Database.db"]; success = [fileManager copyItemAtPath:defaultPath toPath:writableDB error:&amp;error]; if (!success) { NSAssert1(0, @"Failed to create writable DB file: '%@'", [error localizedDescription]); } return writableDB; </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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