Skip navigation.
 
mlbasic bindings question
FROM : Daniel Child
DATE : Wed May 14 21:08:12 2008

Hi All,

I'm trying to get my feet wet with bindings and want to try something 
simpler than the mail example provided online.

All I'm trying to do is to replace the target-action-outlet approach 
with bindings in the simplest case I can think of: a text field whose 
value would correspond to an ivar in the controller. One text field 
would receive the number, a button would click, pass the number to the 
ivar, and redisplay that value in another text field.

First off, is it possible possible to bind directly to an instance 
variable in the controller? In my hyper-basic example, I'm collapsing 
M and C. I thought doing so should be OK, so I tried:

Bind to: Controller
Model Key Path: self.number (number is the ivar) (self presumably 
being the controller)

This didn't work.

Unfortunately, I am also confused about the intended receiver for 
addObserver: forKeyPath:. I thought it would be the ivar (number), but 
I get a warning that NSNumber may not respond to that method (and sure 
enough the docs show that it doesn't). Logically, the second text 
field should "observe" that the model/controller ivar (number) has 
changed. But I thought you were not supposed to use outlets either.

Does this mean you can only use bindings for arrays? Clearly that 
can't be right....

If anyone knows of a "hyper-simple" example dispensing with tables and 
arrays, I'd really appreciate the link....

Thanks.

Daniel

Related mailsAuthorDate
mlbasic bindings question Daniel Child May 14, 21:08
mlRe: basic bindings question Ken Thomases May 14, 23:11
mlRe: basic bindings question Daniel Child May 15, 05:54
mlRe: basic bindings question Ken Thomases May 15, 06:09
mlRe: basic bindings question Daniel Child May 15, 06:43
mlRe: basic bindings question Ken Thomases May 15, 06:54
mlRe: basic bindings question Daniel Child May 16, 04:47
mlRe: basic bindings question Ken Thomases May 16, 05:33