开发者

Interface Builder NSStaticText value needs to be updated every time anything changes in dialog

I have a modal dialog thats building a string. The string is shown to the user, and the user presses checkboxes, radio boxes, etc to build the string. The string exists nowhere - I build it for display in -()builtString; from the configuration of the self.valuesDict.

I can easily wire up the checkboxes via bindings in IB: for example to the files owner (the controller) with self.valuesDict.checkbox开发者_如何学Python1

Also I bound the display of the string to "self.builtString".

But every time any checkbox changes, I want to redisplay the string that's shown to the user.

If I abandon bindings, then I think I can use the [self willChangeValueForKey:@"builtString"], for each checkbox, etc, I think, but that is some messy looking code by the time I deal with them all.

So how do you tell a nstextfield in IB to update every time say self.valuesDict changes?

Thanks for any comments/suggestions.

--Tom


You can specify dependencies between bindings. Just write a class method +(NSSet*) keyPathsForValuesAffectingBuiltString that returns a set with all key paths of properties builtString depends on. Then things bound to your string will also be updated when one of the other properties is changed. For more details and step-by-step instructions you can look at this article.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜