views:

11

answers:

1

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.checkbox1

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

+3  A: 

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.

Sven
Thanks - I don't think I would have found that easily. For others - the article is nice, you don't really need it, though. Just do as Sven says.
Tom Andersen
Yeah, this is kinda hard to find in the documentation. Everything I need that I have to use Google to find out how exactly this method needs to be called.
Sven