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
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 mails | Author | Date |
|---|---|---|
| Daniel Child | May 14, 21:08 | |
| Ken Thomases | May 14, 23:11 | |
| Daniel Child | May 15, 05:54 | |
| Ken Thomases | May 15, 06:09 | |
| Daniel Child | May 15, 06:43 | |
| Ken Thomases | May 15, 06:54 | |
| Daniel Child | May 16, 04:47 | |
| Ken Thomases | May 16, 05:33 |






Cocoa mail archive

