Cocoa touch Core data save触发了一个与UIVerlay无关的异常?
我所做的只是保存一个对象。有什么想法吗?我一点也不使用威利。似乎会触发一些随机函数,这只是一种情况 以下是我在这种特殊情况下看到的一些可能的例外情况:Cocoa touch Core data save触发了一个与UIVerlay无关的异常?,cocoa-touch,core-data,Cocoa Touch,Core Data,我所做的只是保存一个对象。有什么想法吗?我一点也不使用威利。似乎会触发一些随机函数,这只是一种情况 以下是我在这种特殊情况下看到的一些可能的例外情况: 2010-08-05 00:34:49.186 Holidays[30485:207] -[UICalloutBarOverlay controllerWillChangeContent:]: unrecognized selector sent to instance 0x5b53540 2010-08-05 00:34:49.188 Holi
2010-08-05 00:34:49.186 Holidays[30485:207] -[UICalloutBarOverlay controllerWillChangeContent:]: unrecognized selector sent to instance 0x5b53540
2010-08-05 00:34:49.188 Holidays[30485:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICalloutBarOverlay controllerWillChangeContent:]: unrecognized selector sent to instance 0x5b53540'
*** Call stack at first throw:
(
0 CoreFoundation 0x02587919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x026d55de objc_exception_throw + 47
2 CoreFoundation 0x0258942b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x024f9116 ___forwarding___ + 966
4 CoreFoundation 0x024f8cd2 _CF_forwarding_prep_0 + 50
5 CoreData 0x0012e1fb -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] + 1867
6 Foundation 0x00215c1d _nsnote_callback + 145
7 CoreFoundation 0x0255fcf9 __CFXNotificationPost_old + 745
8 CoreFoundation 0x024df11a _CFXNotificationPostNotification + 186
9 Foundation 0x0020b7c2 -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
10 CoreData 0x0006a519 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 89
11 CoreData 0x000d9b33 -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] + 259
12 CoreData 0x0004cf78 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 1352
13 CoreData 0x00086a15 -[NSManagedObjectContext save:] + 149
14 Holidays 0x0000977b -[UIEventDetailController save:] + 752
15 UIKit 0x004abe14 -[UIApplication sendAction:to:from:forEvent:] + 119
16 UIKit 0x006b314b -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
17 UIKit 0x004abe14 -[UIApplication sendAction:to:from:forEvent:] + 119
18 UIKit 0x005356c8 -[UIControl sendAction:to:forEvent:] + 67
19 UIKit 0x00537b4a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
20 UIKit 0x005366f7 -[UIControl touchesEnded:withEvent:] + 458
21 UIKit 0x004cf2ff -[UIWindow _sendTouchesForEvent:] + 567
22 UIKit 0x004b11ec -[UIApplication sendEvent:] + 447
23 UIKit 0x004b5ac4 _UIApplicationHandleEvent + 7495
24 GraphicsServices 0x02dedafa PurpleEventCallback + 1578
25 CoreFoundation 0x02568dc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
26 CoreFoundation 0x024c9737 __CFRunLoopDoSource1 + 215
27 CoreFoundation 0x024c69c3 __CFRunLoopRun + 979
28 CoreFoundation 0x024c6280 CFRunLoopRunSpecific + 208
29 CoreFoundation 0x024c61a1 CFRunLoopRunInMode + 97
30 GraphicsServices 0x02dec2c8 GSEventRunModal + 217
31 GraphicsServices 0x02dec38d GSEventRun + 115
32 UIKit 0x004b9b58 UIApplicationMain + 1160
33 Holidays 0x000021ba main + 84
34 Holidays 0x0000215d start + 53
)
terminate called after throwing an instance of 'NSException'
(gdb)继续
在这个线程中,错误正是我在这里看到的。这就是线索:
-[__NSCFDictionary controllerWillChangeContent:]: unrecognized selector sent to instance 0x5b3e1e0
-[UIImageView controllerWillChangeContent:]: unrecognized selector sent to instance 0x5e3ab10
-[CALayer controllerWillChangeContent:]: unrecognized selector sent to instance 0x5b377d0
这意味着一个通知正在被发布,而该通知的一个接收者已经不在了;很可能是被释放了。对于代码中的每个
-addObserver:
调用,您需要将其与-removeObserver:
匹配。NSNotificationCenter
不会保留与其关联的观察者,但会保留对其的强引用 这不是一个答案,但对于像我这样面对这个问题并为解决方案奋斗了数小时的人来说,也许是一个解决方案。我的案例与海报非常相似,在使用-[CALayer controllerWillChangeContent:]:发送到实例的无法识别的选择器更改细节视图中的属性时,我崩溃了
Sza的评论为我指明了正确的方向。我使用了RedArtisan的代码,但将appDelegate中的init方法从initWithStyle
更改为initWithNibName
,然后在控制器的类文件中再次执行initWithNibName
(哦!)
同样,不是一个具体的答案,但希望能帮助其他人完成任务。谢谢!我已经解决了我的问题。原因是我在代码中创建了UIViewController,并在一个方法中加载了XIB。但是,在我更改ViewDidLoad中的初始化并将控制器实例的释放放在Dealoc中之后,它就工作了。似乎创建XIB然后加载它并来回运行并不是那么简单?你能重新表述这个问题吗?
-[NSNotificationCenter postNotificationName:object:userInfo:]