• 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
Trying To Understand Bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trying To Understand Bindings


  • Subject: Trying To Understand Bindings
  • From: "Bridger Maxwell" <email@hidden>
  • Date: Fri, 12 Dec 2008 23:19:50 -0700

Just when I thought I had bindings down....

I have a custom view subclass (sineWaveView) that the user interacts with to change a property (connectedContact). I would like to bind this to a value (selectedShortRangeContact) in a dictionary (database) in another object (databaseClient). Simple, right? Anyway, I establish the binding like so:

[sineWaveView bind:@"connectedContact" toObject:databaseClient withKeyPath:@"database.selectedShortRangeContact" options:nil];

This seems to only work one-way. When the view sets the property, it gets set in the dictionary. However, when I update the value directly in the dictionary, the view never gets a notification. It is like the binding is one-way. I Googled around, and couldn't quite understand why this was, but decided that perhaps it was because I wasn't using NSObjectController. On this site, http://rails.wincent.com/wiki/Cocoa_bindings_notes , Scott Anguish says "Alway, always use a controller," so I thought it was worth a shot.

Here is the code I used to make the NSObjectController, and then bind the view to the object.

databaseController = [[NSObjectController alloc] initWithContent:databaseClient];
[databaseController bind:@"content.database.selectedShortRangeContact" toObject:sineWaveView withKeyPath:@"connectedContact" options:nil];


This is where I am stuck. It sets up the observing just fine. I know this, because when I enter the wrong keyPath I get an error. For example,

[databaseController bind:@"content.wrongKey.selectedShortRangeContact" toObject:sineWaveView withKeyPath:@"connectedContact" options:nil];

causes the following output:

[<SCPushDatabaseClient 0x1033470> valueForUndefinedKey:]: this class is not key value coding-compliant for the key wrongKey.

So, I set it up correctly and I don't get that error. However, even when it is set up correctly, I get the following error when I the view changes the value:

[<NSObjectController 0x1062fa0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key content.database.selectedShortRangeContact.

So, why isn't NSObjectController key value coding-compliant for a keyPath beginning in "content"? What am I doing wrong here?

Thank You,
Bridger Maxwell
_______________________________________________

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: Trying To Understand Bindings
      • From: Quincey Morris <email@hidden>
    • Re: Trying To Understand Bindings
      • From: Ken Thomases <email@hidden>
    • Re: Trying To Understand Bindings
      • From: Ashley Clark <email@hidden>
    • Re: Trying To Understand Bindings
      • From: "Bridger Maxwell" <email@hidden>
  • Prev by Date: Re: Programmatically constructing list of variable arguments?
  • Next by Date: Re: Resizing an image
  • Previous by thread: Re: How to handle document scaling in an NSRulerView Client?
  • Next by thread: Re: Trying To Understand Bindings
  • Index(es):
    • Date
    • Thread