Cocoa 多值布尔绑定,使用逻辑或
Cocoa Multiple-Value Boolean Bindings, Using Logical OR
所以我想根据 BOOL
隐藏一个视图
我通过 Cocoa 绑定
[view bind:@"hidden" toObject:self withKeyPath:@"someBOOL" options:bindingOptions];
我现在的问题是我还想将另一个 BOOL 绑定到视图。
因此,如果这些 BOOL return YES
中的任何一个,我希望 view
被隐藏
[view bind:@"hidden" toObject:self withKeyPath:@"someBOOL2" options:bindingOptions];
问题是默认情况下,将两个 BOOL 绑定到同一视图默认为逻辑 AND 操作,因此 someBOOL
或 someBOOL2
都没有关系如果另一个不计算为 YES
,则计算为 YES
那么有人知道是否有办法使这些编程布尔绑定使用逻辑 OR 运算符吗?
这是我能找到的唯一相关文档和信息:
https://developer.apple.com/library/content/documentation/Cocoa/Reference/CocoaBindingsRef/Concepts/BindingTypes.html
Multiple-Value Bindings
Multiple-value bindings allow multiple bindings to be created for a
single binding. Creating a binding with the first binding
automatically causes a second binding to be exposed, and so on.
For example, if you bind to the enabled binding, a binding called
enabled2 is exposed. If you bind enabled2, the object will expose
enabled3, and so on. All these binding values are then used together
in returning the final value of the binding.
Multiple-value bindings are always read-only.
There are four variations of multiple-value bindings.
Multiple-Value Boolean Bindings Multiple-value Boolean bindings are
used to determine if an object is editable, hidden, or enabled. The
resulting value of the binding is derived by forming the logical AND
or logical OR of the values of the exposed bindings. The logical
operation used depends on the specific binding.
对于您显示的第二个绑定,您仍在使用名称 "hidden"。这取代了第一个绑定。如果要使用多值绑定,第二个需要使用绑定名称 "hidden2".
如@Willeke 所述,隐藏绑定对多值绑定使用逻辑或。好东西就是你想要的,因为,不,你无法改变它。 :)
所以我想根据 BOOL
隐藏一个视图我通过 Cocoa 绑定
[view bind:@"hidden" toObject:self withKeyPath:@"someBOOL" options:bindingOptions];
我现在的问题是我还想将另一个 BOOL 绑定到视图。
因此,如果这些 BOOL return YES
中的任何一个,我希望 view
被隐藏
[view bind:@"hidden" toObject:self withKeyPath:@"someBOOL2" options:bindingOptions];
问题是默认情况下,将两个 BOOL 绑定到同一视图默认为逻辑 AND 操作,因此 someBOOL
或 someBOOL2
都没有关系如果另一个不计算为 YES
YES
那么有人知道是否有办法使这些编程布尔绑定使用逻辑 OR 运算符吗?
这是我能找到的唯一相关文档和信息: https://developer.apple.com/library/content/documentation/Cocoa/Reference/CocoaBindingsRef/Concepts/BindingTypes.html
Multiple-Value Bindings
Multiple-value bindings allow multiple bindings to be created for a single binding. Creating a binding with the first binding automatically causes a second binding to be exposed, and so on.
For example, if you bind to the enabled binding, a binding called enabled2 is exposed. If you bind enabled2, the object will expose enabled3, and so on. All these binding values are then used together in returning the final value of the binding.
Multiple-value bindings are always read-only.
There are four variations of multiple-value bindings.
Multiple-Value Boolean Bindings Multiple-value Boolean bindings are used to determine if an object is editable, hidden, or enabled. The resulting value of the binding is derived by forming the logical AND or logical OR of the values of the exposed bindings. The logical operation used depends on the specific binding.
对于您显示的第二个绑定,您仍在使用名称 "hidden"。这取代了第一个绑定。如果要使用多值绑定,第二个需要使用绑定名称 "hidden2".
如@Willeke 所述,隐藏绑定对多值绑定使用逻辑或。好东西就是你想要的,因为,不,你无法改变它。 :)