manageObjectContext giving error
todoList *todolist = [NSEntityDescription insertNewObjectForEntityForName:@"todoList" inManagedObjectContext:[self managedObjectContext]];
//todolist1 = [NSEntityDescription insertNewObjectForEntityForName:@"todoList" inManagedObjectContext:self.managedObjectContext];
[patients addTodosObject:todolist];
todolist.todoItem = txtAddTodo.text;
todolist.todoDate = txtTodoDate.text;
todolist.todoTime = txtTodoTime.text;
N开发者_JAVA百科SError *error = nil;
if (![patients.managedObjectContext save:&error]) { //It crashes Here
// Handle error
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
exit(-1); // Fail
}
Please give the error displayed in the console, as suggested by Manu. However, you can try going into the iOS Simulator and selecting iOS Simulator > Reset Content and Settings. By clearing the previous database, this often fixes weird errors associated with Core Data (especially if you're modifying the model).
精彩评论