我在 iOS 上遇到以下崩溃:
Unresolved error Error Domain=NSCocoaErrorDomain Code=1550 "The operation couldn’t be completed. (Cocoa error 1550.)" UserInfo=0x74a30d0 {NSValidationErrorObject=<Exercise: 0x9097d50> (entity: Exercise; id: 0x9097970 <x-coredata://AF762754-4CD9-4386-A453-049CC8710DBF/Exercise/p124> ; data: {
groupId = 21;
id = 102;
intensity = "0x906a7a0 <x-coredata://AF762754-4CD9-4386-A453-049CC8710DBF/Intensity/p125>";
lengthMeasurable = 1;
name = Running;
owner = "0x9096540 <x-coredata:///ExerciseEvent/t6817E9A9-9A4C-4044-BF20-FC15380B7C2F4>";
picId = 2719;
}), NSAffectedObjectsErrorKey=(
"<ExerciseEvent: 0x9090910> (entity: ExerciseEvent; id: 0x9096540 <x-coredata:///ExerciseEvent/t6817E9A9-9A4C-4044-BF20-FC15380B7C2F4> ; data: <fault>)"
), Dangling reference to an invalid object.=null, NSValidationErrorKey=owner, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1550.), NSValidationErrorValue=<ExerciseEvent: 0x9090910> (entity: ExerciseEvent; id: 0x9096540 <x-coredata:///ExerciseEvent/t6817E9A9-9A4C-4044-BF20-FC15380B7C2F4> ; data: <fault>)}, {
"Dangling reference to an invalid object." = "<null>";
NSAffectedObjectsErrorKey = (
"<ExerciseEvent: 0x9090910> (entity: ExerciseEvent; id: 0x9096540 <x-coredata:///ExerciseEvent/t6817E9A9-9A4C-4044-BF20-FC15380B7C2F4> ; data: <fault>)"
);
NSLocalizedDescription = "The operation couldn\U2019t be completed. (Cocoa error 1550.)";
NSValidationErrorKey = owner;
NSValidationErrorObject = "<Exercise: 0x9097d50> (entity: Exercise; id: 0x9097970 <x-coredata://AF762754-4CD9-4386-A453-049CC8710DBF/Exercise/p124> ; data: {\n groupId = 21;\n id = 102;\n intensity = \"0x906a7a0 <x-coredata://AF762754-4CD9-4386-A453-049CC8710DBF/Intensity/p125>\";\n lengthMeasurable = 1;\n name = Running;\n owner = \"0x9096540 <x-coredata:///ExerciseEvent/t6817E9A9-9A4C-4044-BF20-FC15380B7C2F4>\";\n picId = 2719;\n})";
NSValidationErrorValue = "<ExerciseEvent: 0x9090910> (entity: ExerciseEvent; id: 0x9096540 <x-coredata:///ExerciseEvent/t6817E9A9-9A4C-4044-BF20-FC15380B7C2F4> ; data: <fault>)";
}
我在某个时候遇到了这个崩溃,那就是我想将我的模型保存ExerciseEvent
在CoreData
. 所以我在我的视图中创建了一个这样的新实体:
self.ee = [NSEntityDescription insertNewObjectForEntityForName:@"ExerciseEvent" inManagedObjectContext:context]
然后我有 2 个按钮,“保存”和“丢弃”。如果我按“丢弃”,我必须删除该实体,这样我就不会ExerciseEvent
在上下文中获得可为空的值。我在视图中这样删除它:
[context deleteObject:self.ee];
[context save:nil];
然后,当我打开我的所有列表时,ExerciseEvents
如上所述,我会遇到以下崩溃。