且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Cocoa Bindings传播编程式文本字段值更改为模型

更新时间:2023-02-12 09:27:51

绑定值不会更改由Apple的设计。要在更改后自己将值传播给模型,请修改此代码:

The bound value doesn't change by Apple's design. To propagate the value to the model yourself after a change, adapt this code:

NSDictionary *bindingInfo = [self infoForBinding:NSValueBinding];
[[bindingInfo valueForKey:NSObservedObjectKey] setValue:self.doubleValue
                                             forKeyPath:[bindingInfo valueForKey:NSObservedKeyPathKey]];

(感谢@DrummerB的苹果链接!)

(Thanks @DrummerB for that Apple link!)