Swift +核心数据:在swift中生成子类后无法添加托管对象

时间:2015-06-20 19:31:34

标签: swift core-data xcode7

我创建了一个数据模型,如下所示:

enter image description here

将ArrayController实体名更新为:DownloadingFile,并执行相关绑定:

一个。 ArrayController绑定

enter image description here

湾表格列绑定

enter image description here

℃。添加按钮绑定

enter image description here

我点击了“添加”按钮,按预期完美运行:)

然后我在swift中生成了我的托管对象的子类,突然间它开始崩溃,在控制台中打印下面的堆栈跟踪:

2015-06-21 00:38:13.073 TableViewBindingsSample[2390:48630] Failed to create new object
2015-06-21 00:38:13.075 TableViewBindingsSample[2390:48630] (
    0   CoreFoundation                      0x00007fff838b703c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8687d76e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff838b6e1a +[NSException raise:format:arguments:] + 106
    3   AppKit                              0x00007fff84fd34c9 _NSSendCommitEditingSelector + 267
    4   AppKit                              0x00007fff84fd35ab -[NSController _controllerEditor:didCommit:contextInfo:] + 185
    5   CoreFoundation                      0x00007fff8378e7bc __invoking___ + 140
    6   CoreFoundation                      0x00007fff8378e612 -[NSInvocation invoke] + 290
    7   CoreFoundation                      0x00007fff8382e5c6 -[NSInvocation invokeWithTarget:] + 54
    8   Foundation                          0x00007fff8812b41b __NSFireDelayedPerform + 364
    9   CoreFoundation                      0x00007fff8380a2e4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    10  CoreFoundation                      0x00007fff83809f73 __CFRunLoopDoTimer + 1059
    11  CoreFoundation                      0x00007fff8387d53d __CFRunLoopDoTimers + 301
    12  CoreFoundation                      0x00007fff837c5608 __CFRunLoopRun + 2024
    13  CoreFoundation                      0x00007fff837c4bd8 CFRunLoopRunSpecific + 296
    14  HIToolbox                           0x00007fff8c3cf56f RunCurrentEventLoopInMode + 235
    15  HIToolbox                           0x00007fff8c3cf1ee ReceiveNextEventCommon + 179
    16  HIToolbox                           0x00007fff8c3cf12b _BlockUntilNextEventMatchingListInModeWithFilter + 71
    17  AppKit                              0x00007fff84c429bb _DPSNextEvent + 978
    18  AppKit                              0x00007fff84c41f68 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346
    19  AppKit                              0x00007fff84c37bf3 -[NSApplication run] + 594
    20  AppKit                              0x00007fff84bb4354 NSApplicationMain + 1832
    21  TableViewBindingsSample             0x0000000100003c87 main + 87
    22  libdyld.dylib                       0x00007fff865225c9 start + 1
    23  ???                                 0x0000000000000003 0x0 + 3
)

所以我试着去谷歌并找到一个开发人员提出的解决方案:Failed to Create Object - Simple Core Data App但在我的情况下,建议的解决方案不起作用,实际上我无法将项目名称添加为类名的前缀以点分隔,当我尝试这样做时,Xcode会自动删除添加的点:(

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

我通过从生成的NSManagedObject子类中删除@objc(EntityName)来实现它。