Re: Path from a NSDictionary
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.