【发布时间】:2012-05-05 04:20:28
【问题描述】:
我一定遗漏了一些非常明显的东西,但我已经翻遍了,找不到解决办法。
在 Interface Builder 中,我已将 NSNumberFormatter 连接到 NSTextField,我已将值绑定到浮点值。这一切都按预期工作,数字得到验证和更新。除非我输入一个空字符串,否则我会得到一个异常:
Exception detected while handling key input.
[<ResolutionSetting 0x11d029430> setNilValueForKey]: could not set nil as the value for the key scale.
如果文本字段为空,有什么方法可以让 NSTextField 返回一个空字符串 (@"") 而不是 nil?或者,有没有办法让 NSNumberFormatter 处理 nil 值?
【问题讨论】:
标签: cocoa interface-builder cocoa-bindings nstextfield nsnumberformatter