• 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: Path from a NSDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Path from a NSDictionary


  • Subject: Re: Path from a NSDictionary
  • From: Daniel Zitter <email@hidden>
  • Date: Thu, 15 May 2003 09:30:36 -0700

Parichay,

A solution should not be difficult. One woudl just traverse the dictionary depth-first order and build up the paths.

It is natural to think of the solution in terms of the recursive structure of the dictionary of dictionaries and strings, and convenient to implement it terms of an enumerator, something like:

@interface MyDictionaryEnumerator : NSEnumerator
{
NSString *prefix;
NSDictionary *dict;
NSEnumerator *keyEnumerator; // enumerator of dict's keys
NSEnumerator *subEnumerator; // for recursion into sub-dictionary
}
- (id)initWithDictionary:(NSDictionary *)aDictionary prefix:(NSString *)aPathPrefix;

/* returns path prefix concatenated with
-the next key concatenated with the string value for the key, or
-the next key concatenated with the nextObject(s) from a new enumerator (recursion) of the
dictionary value for the key
*/
- nextObject;

- (void)dealloc;
@end


Cheers,
Dan

Message: 5
From: "Parichay Gupta" <email@hidden>
To: <email@hidden>
Subject: Path from a NSDictionary
Date: Thu, 15 May 2003 15:50:15 +0530

Hi,

I'm writing an application using Cocoa/Objective-C. In my application, I have
a propertylist NSDictionary, the content of which is something like the
following:
<dict>

<key>Key1</key>

<dict>

<key>Key11</key>

<dict>

<key>Key111</key>

<string>String1</string>

<key>Key112</key>

<string>String2</string>

</dict>

</dict>

</dict>

Using the method writeToFile, I need to write the content of the dictionary
into a file in the following format:

/Key1/Key11/Key111

/Key1/Key11/Key112

Can anybody give me a hint, how will I create the above-mentioned path for a
key?

TIA,

Parichay Gupta
_______________________________________________
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.

  • Prev by Date: RE: NSPopUpButton failure after adding file names
  • Next by Date: Re: writeToFile method of NSArray
  • Previous by thread: Path from a NSDictionary
  • Next by thread: NSPopUpButton failure after adding file names
  • Index(es):
    • Date
    • Thread