• 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
Re: Setting up bindings using GC and properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting up bindings using GC and properties


  • Subject: Re: Setting up bindings using GC and properties
  • From: mmalc crawford <email@hidden>
  • Date: Sat, 3 Nov 2007 05:37:49 -0700


On Nov 2, 2007, at 10:52 PM, Sam Stigler wrote:

I've been trying to get the hang of this for the past several hours, but I still can't get it right: What is the correct way to initialize (by which I mean set an initial value) for a binding in a project using garbage collection and properties?

Exactly as you would with managed memory.
GC is an orthogonal technology to bindings.

I think I'm following the examples fairly well, but I keep on getting "__TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION__" errors saying that my class isn't KVC-compliant for a given property.

That's because the class in question is not...

The relevant text field's binding is to the dictionary controller in question, with controller key "selection", model key path "bonjourOnOff", and my own custom value transformer. I've checked the spelling, and it looks like there are no mistakes there.

Replicating what you did, the error message is likely to be something like:

2007-11-03 05:21:52.075 Dictionary[661:10b] [<_NSControllerKeyValuePair 0x1774e0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key bonjourOnOff.

Note that it's reporting * _NSControllerKeyValuePair * isn't KVC compliant for...


Per the documentation:
"The arrangedObjects method returns an array of objects that implement the NSDictionaryControllerKeyValuePair informal protocol. User interface controls are bound to the arranged objects array using key paths such as: arrangedObjects.key (displays the key name), arrangedObjects.value (displays the value for the key), or arrangedObjects.localizedKey (displays the localized key name). See NSDictionaryControllerKeyValuePair Protocol Reference for more information."


<http://developer.apple.com/documentation/Cocoa/Reference/NSDictionaryController_Class/Introduction/Introduction.html >



so 'selection' will return the currently-selected key-value pair, with keys defined by the NSDictionaryControllerKeyValuePair protocol.



If you want to display the value for bonjourOnOff, bind to [File's Owner].serverStatus.bonjourOnOff

(assuming that File's Owner is the object for which you gave the init method).



mmalc


_______________________________________________

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:
    • [SOLVED] Re: Setting up bindings using GC and properties
      • From: Sam Stigler <email@hidden>
References: 
 >Setting up bindings using GC and properties (From: Sam Stigler <email@hidden>)

  • Prev by Date: Re: Setting up bindings using GC and properties
  • Next by Date: Re: Adding an icon to the dock
  • Previous by thread: Re: Setting up bindings using GC and properties
  • Next by thread: [SOLVED] Re: Setting up bindings using GC and properties
  • Index(es):
    • Date
    • Thread