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;
NSError *error = nil;
if (![patients.managedObjectContext save:&error]) { //It crashes Here
// Handle error
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
exit(-1); // Fail
}
答案 0 :(得分:0)
请按照Manu的建议给出控制台中显示的错误。但是,您可以尝试进入iOS模拟器并选择iOS模拟器>重置内容和设置。通过清除以前的数据库,这通常可以修复与Core Data相关的奇怪错误(特别是如果您正在修改模型)。