我有一个viewController,它插入新的Core数据对象。我的问题是,我的保存功能出现以下错误:
[Messdiener_Memory.Spiel managedObjectModel]: unrecognized selector sent to instance 0x7fddebf7e220'
*** First throw call stack:
(
0 CoreFoundation 0x0000000103e20d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001064cddeb objc_exception_throw + 48
2 CoreFoundation 0x0000000103e29d3d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000103d6fcfa ___forwarding___ + 970
4 CoreFoundation 0x0000000103d6f8a8 _CF_forwarding_prep_0 + 120
5 CoreData 0x000000010397a4f3 -[NSManagedObject initWithEntity:insertIntoManagedObjectContext:] + 83
6 Messdiener-Memory 0x0000000103818d7c _TFC17Messdiener_Memory6PersoncfT6entityCSo19NSEntityDescription30insertIntoManagedObjectContextGSqCSo22NSManagedObjectContext__S0_ + 76
7 Messdiener-Memory 0x000000010384b466 _TFC17Messdiener_Memory20NeuesSpielController19fertigButtonPressedfCSo15UIBarButtonItemT_ + 3542
8 Messdiener-Memory 0x000000010384b98a _TToFC17Messdiener_Memory20NeuesSpielController19fertigButtonPressedfCSo15UIBarButtonItemT_ + 58
9 UIKit 0x0000000104f53a8d -[UIApplication sendAction:to:from:forEvent:] + 92
10 UIKit 0x0000000105361067 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 152
11 UIKit 0x0000000104f53a8d -[UIApplication sendAction:to:from:forEvent:] + 92
12 UIKit 0x00000001050c6e67 -[UIControl sendAction:to:forEvent:] + 67
13 UIKit 0x00000001050c7143 -[UIControl _sendActionsForEvents:withEvent:] + 327
14 UIKit 0x00000001050c72be -[UIControl _sendActionsForEvents:withEvent:] + 706
15 UIKit 0x00000001050c6263 -[UIControl touchesEnded:withEvent:] + 601
16 UIKit 0x0000000104fc699f -[UIWindow _sendTouchesForEvent:] + 835
17 UIKit 0x0000000104fc76d4 -[UIWindow sendEvent:] + 865
18 UIKit 0x0000000104f72dc6 -[UIApplication sendEvent:] + 263
19 UIKit 0x0000000104f4c553 _UIApplicationHandleEventQueue + 6660
20 CoreFoundation 0x0000000103d46301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21 CoreFoundation 0x0000000103d3c22c __CFRunLoopDoSources0 + 556
22 CoreFoundation 0x0000000103d3b6e3 __CFRunLoopRun + 867
23 CoreFoundation 0x0000000103d3b0f8 CFRunLoopRunSpecific + 488
24 GraphicsServices 0x000000010957ead2 GSEventRunModal + 161
25 UIKit 0x0000000104f51f09 UIApplicationMain + 171
26 Messdiener-Memory 0x0000000103842502 main + 114
27 libdyld.dylib 0x0000000106f9a92d start + 1
28 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
我知道的一切都是错误必须在行spiel之后!.personen = NSSet(array:temp)并且不会打印catch中的错误。
spiel!.gruppen = NSOrderedSet(array: gruppen)
spiel!.personen = NSSet(array: temp)
spiel?.maxPunkte = gesamtPunkte
do {
try managedContext.save()
//5
print("YES")
app?.aktivesSpiel(spiel)
self.navigationController?.popViewControllerAnimated(true)
} catch let error as NSError {
print("Could not save \(error), \(error.userInfo)")
}
感谢您的帮助。