Fwd: Creating Parent and Child CFXMLNodesRefs
Fwd: Creating Parent and Child CFXMLNodesRefs
- Subject: Fwd: Creating Parent and Child CFXMLNodesRefs
- From: email@hidden
- Date: Sat, 27 Jul 2002 00:30:03 -0400
I recently sent this to the carbon-dev list as well, but the more
insight I get, the better. Thank you.
Begin forwarded message:
I have created (in objc) a class that is a subclass of NSDictionary,
called OrderedDictionary, which records the key in a NSArray member
variable (for each new entry) and the key/value pair in a NSDictionary
member variable. The result is an ordered "dictionary." (I then
subsequently subclassed OrderedDictionary to produce
MutableOrderedDictionary, which just allows for the addition and
deletion of entries).
Now I want to write an instance of one of these ordered dictionaries as
an XML file in a way that is exactly the same as with NSDictionary
objects (the same as for CFDictionaryRefs). Since I implemented what
are called the "primitive methods" of the class cluster under
NSDictionary, the method writeToFile:atomically: should work properly
without any overriding (re-implementation), and in fact it does, but
wrongly.
It turns out that the writeToFile:atomically: method still writes the
OrderedDictionary object's key/value pairs sporadically --possibly
because the Cocoa implementation makes use of a CFDictionaryRef.
Anyhow, I set off to override writeToFile:atomically: with the
low-level XML routines in CoreFoundation, but I have run into a problem
(truly, how to actually do it):
I need to loop through the NSArray member variable (which holds the
keys in order) and write those values out as <key>key</key> in the
appropriate way, and after each key, write the value of each key
(gotten from the NSDictionary member variable) in the usual way.
This should be easy enough, for I just have to create a bunch of
CFXMLNodesRefs with the proper information, but:
I see that I can create CFXMLNodeRefs with CFXMLNodeCreate() and then
create a CFXMLTreeRef with CFXMLTreeCreateWithNode(). However, that
doesn't seem very useful, since that would give me a CFXMLTreeRef with
only one CFXMLNodeRef, and I need a tree with nodes and then child
nodes (key and value nodes in the <dict> element node, and then some...
for any values that are containers). In other words, I need to create a
more complex CFXMLTreeRef object (is that what it would be called, and
object?)
To end all of this, somebody please tell me what to do. Thank you.
_______________________________________________
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.