随机崩溃的我的应用程序

时间:2010-09-10 03:05:44

标签: cocoa crash

我只是为我的应用中的偏好设置窗口编写了更多内容,我运行它,我得到以下错误: 2010-09-09 20:01:08.099 YM2612[12060:80f] An uncaught exception was raised

2010-09-09 20:01:08.102 YM2612[12060:80f] Cannot create BOOL from object <_NSControllerObjectProxy: 0x34cd30> of class _NSControllerObjectProxy

2010-09-09 20:01:08.105 YM2612[12060:80f] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot create BOOL from object

<_NSControllerObjectProxy: 0x34cd30> of class _NSControllerObjectProxy'

*** Call stack at first throw:

(

0   CoreFoundation                      0x90d9ebba __raiseError + 410

1   libobjc.A.dylib                     0x93aab509 objc_exception_throw + 56

2   CoreFoundation                      0x90d9e8e8 +[NSException raise:format:arguments:] + 136

3   AppKit                              0x925ae0ed _NSHandleBindingException + 108

4   AppKit                              0x91ff0652 _NSBoolFromValue + 490

5   AppKit                              0x920f226f -[_NSCheckBoxPlugin showValue:inObject:] + 144

6   AppKit                              0x91fbdb69 -[NSValueBinder showValue:inObject:] + 384

7   AppKit                              0x91fbd5b9 -[NSValueBinder _adjustObject:mode:observedController:observedKeyPath:context:editableState:adjustState:] + 906

8   AppKit                              0x91fbd1af -[NSValueBinder _observeValueForKeyPath:ofObject:context:] + 280

9   AppKit                              0x91f379ad -[NSBinder _performConnectionEstablishedRefresh] + 85

10  AppKit                              0x91f2a0b8 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 721

11  AppKit                              0x91fd6003 -[NSNibBindingConnector establishConnection] + 156

12  AppKit                              0x91f053f3 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1249

13  AppKit                              0x91f03508 loadNib + 257

14  AppKit                              0x91f02900 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 228

15  AppKit                              0x91f02811 +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 158

16  AppKit                              0x91f0275c +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 383

17  AppKit                              0x91eff561 NSApplicationMain + 434

18  YM2612                              0x00002844 main + 30

19  YM2612                              0x000027fa start + 54

)

1 个答案:

答案 0 :(得分:5)

阅读你收到的信息:

2010-09-09 20:01:08.102 YM2612[12060:80f] Cannot create BOOL from object <_NSControllerObjectProxy: 0x34cd30> of class _NSControllerObjectProxy

该东西无法转换为BOOL。猜测一下,它是一个对象控制器selection,它是该对象的类名所代表的代理。

那么,为什么要尝试将其转换为BOOL呢?为此,您查看堆栈跟踪:

4   AppKit                              0x91ff0652 _NSBoolFromValue + 490
5   AppKit                              0x920f226f -[_NSCheckBoxPlugin showValue:inObject:] + 144
6   AppKit                              0x91fbdb69 -[NSValueBinder showValue:inObject:] + 384
7   AppKit                              0x91fbd5b9 -[NSValueBinder _adjustObject:mode:observedController:observedKeyPath:context:editableState:adjustState:] + 906
8   AppKit                              0x91fbd1af -[NSValueBinder _observeValueForKeyPath:ofObject:context:] + 280
9   AppKit                              0x91f379ad -[NSBinder _performConnectionEstablishedRefresh] + 85
10  AppKit                              0x91f2a0b8 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 721
11  AppKit                              0x91fd6003 -[NSNibBindingConnector establishConnection] + 156
12  AppKit                              0x91f053f3 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1249

你正在加载一个笔尖,并且,作为其中的一部分,它正在连接你在IB中设置的绑定。

因此,您将需要BOOL的属性绑定到其值无法转换为BOOL的属性。您需要查看nib(第16帧到第17帧建议的接近是MainMenu.nib)来查看绑定的布尔属性以及绑定它们的内容,并绑定绑定到控制器{{1对更有意义的事情。

也许你打算用selection作为模型关键路径绑定到控制器的selectedObjects(这是一个数组,而不是代理对象)?

您最有可能绑定的绑定采用布尔值为任何控件的@countenabled(按钮,文本字段,滑块等)。但是,它们不是唯一的,所以你需要查看具有绑定绑定的每个对象,特别是如果你已经连接的任何editable / enabled绑定不要成为罪魁祸首。