• 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 17:01:36 -0800

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.

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

  • Prev by Date: Odd memory issue -- not a newbie
  • Next by Date: table sizing question
  • Previous by thread: NSArray NSDictionary Tree Q.
  • Next by thread: Re: NSArray NSDictionary Tree Q.
  • Index(es):
    • Date
    • Thread