views:

68

answers:

1

I'm writing a countdown timer and instead of calling -[NSTextField setDoubleValue:secondsRemaining] on each tick, I'd like to bind the secondsRemaining property to an interface element via an object controller.

The problem with this is that secondsRemaining is modified by code on each tick, not by the interface, so the change is doesn't seem to be broadcast.

I have two parts to the question:

1) Is this a sensible way to use bindings or should I stick with -[NSTextField setDoubleValue:] in my App controller?

2) If I do use bindings, how do inform the interface that the value has changed?

Thanks!

+4  A: 

Either use a KVO-compliant setter or send manual notifications when you mutate the value.

Chuck
Preferably the former. It's much, *much* easier.
Peter Hosey