I'm using fmdb (https://github.com/ccgus/fmdb) to insert data into sqlite. I'm talking directly to sqlite instead of using Core Data just because I feel it gives me more flexibility in my queries and I'm good at SQL so it's easy for me.
The problem I'm noticing when running in XCode5 using the simulator is when I turn off my Mac and then turn it back on, none of my SQLite data that I inserted is persisted. The tables are empty. I don't have a Apple Device besides my Mac, so as of yet I've been unable to test this on an actual device, so maybe this is just a Simulator thing, and if that's the case I'd be ok with that.
Here's a typical insert for me:
-(BOOL)insertLocation:(BTRLocation *)location {
NSMutableDictionary *dictionaryArgs = [NSMutableDictionary dictionary];
[dictionaryArgs setObject:location.address forKey:@"columnA"];
[dictionaryArgs setObject:location.name forKey:@"columnB"];
return [self.db executeUpdate:@"insert into locs (columnA, columnB) values (:columnA, :columnB)" withParameterDictionary:dictionaryArgs];
}
It wouldn't appear that anything is wrong with my query because it does work. Even if I kill the app by hitting the Stop button in XCode and then relaunch it, all of the data is persisted. It just doesn't make it through computer shut downs. I find this a little bit weird because NSUserDefaults seem to get persisted through computer shut downs.
Help?
Edit: A bit of extra information I found: It would seem it's not just my data in the tables that don't exist anymore on restart, it's the tables themselves. I always do this on app startup:
FMResultSet *rs = [self.db executeQuery:@"select DISTINCT tbl_name from sqlite_master where tbl_name = ?", table];
[rs next];
BOOL errors = NO;
if([rs hasAnotherRow]) {
// table exists - I think -> So here we would do nothing
NSLog(@"locs table existed");
} else {
NSLog(@"locs table does not exist");
And it always hits the if (locs table existed) except for the first time starting up the app after a computer restart.