代码之家  ›  专栏  ›  技术社区  ›  Tristan

我的应用程序随机崩溃

  •  1
  • Tristan  · 技术社区  · 14 年前

    我刚刚在我的应用程序中为“首选项”窗口编写了更多的代码,运行它时,出现以下错误: 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 回复  |  直到 14 年前
        1
  •  6
  •   Peter Hosey    14 年前

    阅读你收到的信息:

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

    那东西不能转换成 BOOL . 一猜,这是一个对象控制器的 selection ,正如该对象的类名所示,它是一个代理。

    ? 为此,请查看堆栈跟踪:

    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
    

    所以,您绑定了一个需要 布尔 无法将其值转换为 . 您需要查看笔尖(第16帧到第17帧的接近度表明主菜单.nib)查看绑定了哪些布尔属性,以及将它们绑定到了什么,并将绑定到控制器的 选择

    selectedObjects (这是一个数组,而不是一个代理对象) @count

    最有可能使用布尔值绑定的绑定是 enabled editable 任何控件(按钮、文本字段、滑块等)。但是,它们不是唯一的,所以您需要查看每个具有绑定的对象,特别是如果有的话 启用 / 可编辑