我正在将一些代码从使用IBOutlets转换为Cocoa绑定。屏幕非常简单:
我的Swift类中的声明是:
class UnitsVC : NSViewController {
private var deck: Deck?
dynamic var CurrentUnits: String = "Meters"
dynamic var CurrentScale: Double = 1.0
dynamic var NewUnits: String = "Meters"
dynamic var NewScale: Double = 1.0
dynamic var Scale: Double = 1.0
dynamic var ChangeDimensions: Bool = true
dynamic var ChangeDiameters: Bool = true
dynamic var ChangeUnitsToBase: Bool = false
但是当我显示屏幕时,我得到了:
2016-04-08 08:39:31.563 SwiftNEC[73176:5317145] An uncaught exception was raised
2016-04-08 08:39:31.563 SwiftNEC[73176:5317145] Cannot create BOOL from object <SwiftNEC.UnitsVC: 0x618000164ec0> of class SwiftNEC.UnitsVC
2016-04-08 08:39:31.567 SwiftNEC[73176:5317145] (
0 CoreFoundation 0x00007fff93e044f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff8a91673c objc_exception_throw + 48
2 CoreFoundation 0x00007fff93e091ca +[NSException raise:format:arguments:] + 106
3 AppKit 0x00007fff949b65a4 _NSHandleBindingException + 302
4 AppKit 0x00007fff943f583e _NSBoolFromValue + 386
5 AppKit 0x00007fff94492a4b -[_NSCheckBoxPlugin showValue:inObject:] + 71
6 AppKit 0x00007fff942d0b18 -[NSValueBinder _adjustObject:mode:observedController:observedKeyPath:context:editableState:adjustState:] + 463
7 AppKit 0x00007fff942d08b9 -[NSValueBinder _observeValueForKeyPath:ofObject:context:] + 296
8 AppKit 0x00007fff94221865 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 758
显然,其中一个复选框的连线不正确。但是哪一个?绑定中似乎没有任何东西似乎是错误的。我绑定到每个框的值,并检查绑定和连接,我看不到任何其他内容:
我甚至试图删除我能看到的所有绑定,但我仍然遇到同样的问题。
那么,我该如何调试呢?似乎没有任何有用的东西是在调试器输出中吐出,特别是密钥,这将指示问题。有没有办法获得这些信息?