• 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: Binding to an array of dictionaries as a to-many
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding to an array of dictionaries as a to-many


  • Subject: Re: Binding to an array of dictionaries as a to-many
  • From: mmalcolm crawford <email@hidden>
  • Date: Mon, 21 Mar 2005 04:46:18 -0800


On Mar 21, 2005, at 1:44 AM, Paul Collins wrote:

My bindings-driven view of some custom objects is working well, except for one thing. I have a class MyRecord containing an ivar iPersons, containing an NSArray of NSDictionaries. One of the keys in the dictionaries is "Name".

(Note:
<http://developer.apple.com/documentation/Cocoa/Conceptual/ KeyValueCoding/Concepts/BasicPrinciples.html>
"Keys must use ASCII encoding and begin with a lowercase letter.")


I want to obtain the array of a particular key's values from those dictionaries, which KVC docs say can be done with dot notation. When I bind an NSTableColumn to this, I get this error:
[<NSCFArray 0x579b60> addObserver:forKeyPath:options:context:] is not supported. Key path: Name

Are you trying to bind the value of a table column to the resulting array?


You can add an accessor method for names, e.g.:

- (NSArray *)names
{
    return [iPersons valueForKey:@"name"];
}

(You'll probably also have to set up a key dependency using setKeys:triggerChangeNotificationsForDependentKey:.)


To diagnose, I tried accessing the data directly with KVC:
NSArray *names = [myRecordInstance valueForKey:@"iPersons.Name"];
But I get an exception saying: [<MyRecord 0x537b20> valueForUndefinedKey:]: this class is not key value coding- compliant for the key iPersons.Name.

NSArray *names = [myRecordInstance valueForKeyPath:@"iPersons.Name"];


mmalc

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Binding to an array of dictionaries as a to-many (From: Paul Collins <email@hidden>)

  • Prev by Date: Re: NSTimer causes events to be lost
  • Next by Date: Re: Reading .BMPs the hard way
  • Previous by thread: Binding to an array of dictionaries as a to-many
  • Next by thread: Re: Binding to an array of dictionaries as a to-many
  • Index(es):
    • Date
    • Thread