• 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: NSArray NSDictionary Tree Q.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray NSDictionary Tree Q.


  • Subject: Re: NSArray NSDictionary Tree Q.
  • From: Ian McGregor <email@hidden>
  • Date: Sat, 13 Dec 2003 23:06:06 -0800

Hi Scott,

In my docs for NSDictionary it reads:

valueForKey:

- (id)valueForKey:(NSString *)key

Returns the result of sending objectForKey: to the receiver.

Availability

Available in Mac OS X v10.3 and later.

See Also:  setValue:forKey: (NSMutableDictionary)


A mistake perhaps??

Cheers,

Ian


On 13-Dec-03, at 10:44 PM, Scott Anguish wrote:

> valueForKey: and valueForKeyPath have been around for quite a while,
> and aren't new for 10.3
>
> You can determine the version of the OS that a method is available for
> by looking at the reference docs.. those that are new (since 10.2.6 I
> think) are noted as such...
>
>
> On Dec 13, 2003, at 8:01 PM, Ian McGregor wrote:
>
>> Thanks Aaron.
>>
>> Unfortunately the app has to run on 10.2.x, and as I understand it
>> (now) the valueForKey is a new 10.3 only thing. Thanks for the
>> explanation of it though. It actually makes more sense now!
>>
>> Cheers,
>>
>> Ian
>>
>> On 13-Dec-03, at 4:30 PM, Aaron Tuller wrote:
>>
>>> if i understand you correctly, yes, use Key Value Coding, it's
>>> already implemented on NSDictionary.
>>>
>>> say you now write something like this:
>>>
>>> [[[someDict objectForKey:@"key1"] objectForKey:@"key2"]
>>> objectForKey:@"key3"]
>>>
>>> you can do:
>>>
>>> [someDict valueForKeyPath:@"key1.key2.key3"];
>>>
>>> where the keypath is any NSString, you could store it externally or
>>> generate it at runtime.
>>>
>>> and there's also
>>>
>>> - (void)takeValue:(id)value forKeyPath:(NSString *)key;
>>>
>>> so you could set the value at a certain path.
>>>
>>> check out:
>>>
>>> http://developer.apple.com/documentation/Cocoa/Conceptual/
>>> KeyValueCoding/index.html
>>>
>>> if this isn't what you're asking, sorry for the noise.
>>>
>>> -aaron
>>>
>>> At 10:01 AM -0800 12/13/03, Ian McGregor wrote:
>>>> I have an immutable NSArray containing a tree-like data structure.
>>>>
>>>> NSArray *rootItems
>>>> - NSDictionary item
>>>> - NSDictionary item
>>>> - NSDictionary item
>>>>
>>>> each NSDictionary item contains an NSArray *children, which can
>>>> contains even more NSDictionary *item objects.
>>>>
>>>> Basically a tree using NSArray and NSDictionary
>>>>
>>>> My model requires these objects to be stored in an immutable
>>>> fashion,
>>>> but I make a mutable copy when I am altering the data, no dramas or
>>>> probs there.
>>>>
>>>> The problem I am having, is finding an easier method the traverse
>>>> the
>>>> "nodes" or NSDictionary *item's to change their values.
>>>>
>>>> For example, if am currently using unique id's for the group nodes,
>>>> and
>>>> another set of unique id's for the object nodes. I have had some
>>>> success using various recursive methods to locate the nodes I wish
>>>> to
>>>> change, but actually changing the node is confusing me.
>>>>
>>>> Any suggestions?
>>>> _______________________________________________
>>>> cocoa-dev mailing list | email@hidden
>>>> Help/Unsubscribe/Archives:
>>>> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>>>> Do not post admin requests to the list. They will be ignored.
>> _______________________________________________
>> cocoa-dev mailing list | email@hidden
>> Help/Unsubscribe/Archives:
>> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>> Do not post admin requests to the list. They will be ignored.
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >NSArray NSDictionary Tree Q. (From: Ian McGregor <email@hidden>)
 >Re: NSArray NSDictionary Tree Q. (From: Ian McGregor <email@hidden>)
 >Re: NSArray NSDictionary Tree Q. (From: Scott Anguish <email@hidden>)

  • Prev by Date: Re: NSArray NSDictionary Tree Q.
  • Next by Date: Re: Are multiple dylibs in one framework possible?
  • Previous by thread: Re: NSArray NSDictionary Tree Q.
  • Next by thread: Re: NSArray NSDictionary Tree Q.
  • Index(es):
    • Date
    • Thread