I have a text field and a slider that are bound to the same NSNumber object. I want to put another label that updates itself once the value on the text field changes (or once the slider's value changes). For example, if the value shown in the text field is increased above 50, how do I get the label to change from "Low" to "High"?

有帮助吗?

解决方案

KVO is certainly a way to go.

On the other hand, you could also take advantage of the targeted action that gets fired off when you adjust the slider. Why not update the backing instance variable or property behind the second text label from the action that you're calling?

其他提示

KVO would be the easiest.

Bindings could be done with a predicate and a formatter.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top