• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
basic bindings question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

basic bindings question


  • Subject: basic bindings question
  • From: Daniel Child <email@hidden>
  • Date: Wed, 14 May 2008 15:08:12 -0400

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
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: basic bindings question
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: Launching Cocoa Application externally
  • Next by Date: Setting default application for URL scheme
  • Previous by thread: Re: show/hide NSTabView
  • Next by thread: Re: basic bindings question
  • Index(es):
    • Date
    • Thread