gpt4 book ai didi

objective-c - Cocoa 多值 bool 绑定(bind),使用逻辑 OR

转载 作者:行者123 更新时间:2023-12-03 16:56:38 26 4
gpt4 key购买 nike

所以我有一个想要根据 BOOL 隐藏的 View

我通过 Cocoa Bindings 完成此操作

[view bind:@"hidden" toObject:self withKeyPath:@"someBOOL" options:bindingOptions];

我现在的问题是我想要另一个 BOOL 也绑定(bind)到 View 。

因此,如果这些 BOOL 中的任何一个返回 YES,我希望隐藏 view

[view bind:@"hidden" toObject:self withKeyPath:@"someBOOL2" options:bindingOptions];

问题是,默认情况下,将两个 BOOL 绑定(bind)到同一 View 默认为逻辑 AND 运算,因此无论是 someBOOL 还是 someBOOL2 都没有关系如果另一个计算结果不为 YES,则 计算结果为 YES

那么有人知道是否有办法让这些编程 bool 绑定(bind)使用逻辑 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.

最佳答案

对于您所显示的第二个绑定(bind),您仍然使用名称“hidden”。这将取代第一个绑定(bind)。如果您想使用多值绑定(bind),第二个需要使用绑定(bind)名称“hidden2”。

正如 @Willeke 所指出的,隐藏绑定(bind)对多值绑定(bind)使用逻辑 OR。好消息就是你想要的,因为,不,你无法改变它。 :)

关于objective-c - Cocoa 多值 bool 绑定(bind),使用逻辑 OR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43331755/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com