Saved data gets reset after restarting iphone app simulator
In my iphone app am creating some records and storing them into core data. Everything works fine. But when I restart the simulator, the data is gone and I have to insert it again.
I am pretty sure am saving the data to core data. The code looks like:
WorkItem *myObject = (WorkItem *)[[NSManagedObject alloc] initWithEntity:[NSEntityDescription entityForName:@"WorkItem" inMa开发者_开发知识库nagedObjectContext:self
.managedObjectContext] insertIntoManagedObjectContext:self.managedObjectContext];
myObject.descriptionText = @"My description";
myObject.title = @"My Title.";
myObject.URL = @"URL";
myObject.state = @"myStatus1";
myObject.priority = @"myPriority1";
if (![myObject.managedObjectContext save:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
Kindly let me know if am missing something
I would do these things:
Single step the code in debug mode to make sure you are writing without an error.
Grab something that can read an SQLLite db and open the database to make sure you are writing the data to it.
Make sure you are not creating a new database with every run of your application.
精彩评论