A strange constructor question
A strange constructor question
- Subject: A strange constructor question
- From: Jamie <email@hidden>
- Date: Mon, 21 Jun 2004 10:45:28 +0100
Hi there.
I mailed a few days ago explaining that I was working on a project
which initialises various objects by becoming the delegate for an
NSXMLParser.
I have now hit what seems to me to be a difficult design issue.
Basically I have an object that is initialising it's instance variables
using the XMLParser by repeatedly calling
- (void) parser:(NSXMLParser *)parser
didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
and dealing with each of the relevant elements in turn. The problem
is that this is not all done during one call to the function, but over
multiple iterations, therefore it makes it impossible to use things
such as an NSDictionary to hold some of the values. Let me explain in
more detail:
The object in question describes a software suite, and has instance
variables such as "Name", "Blurb" etc... It also has to hold data
about the various locations of it's data items (files and folders
associated with it). So in the XML config file, under the relevant
section I have a section called "data". Under that there is a list of
child elements, either <folder> or <file> elements.
What I wanted to to was to have an NSDictionary called "data" as an
instance variable of the object. This would in turn hold two
NSArray's, one called "files" and one called "folders". Each array
would be populated in turn with the relevant information from the
configuration file.
This would work fine if the NSDictionary was initialised from one
function call, since I could build two mutable array's, convert the to
normal arrays, and assign them to an NDDictionary. Over multiple calls
however, this is not possible, since I cannot make the temporary
mutable array's local variables in the mehtod. They must be instance
variables instead, and it seems to me I have to write some very
complicated accessors to make this structure feasible.
Am I going about this the wrong way, or is this the only way to get
things done in this case?
Many thanks for your thoughts.
--
jkp
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGP 8.0.3
mQGiBEAvrCkRBADP0l+qGhYxe7VZe8NhHPvHKGfYEzMg/FpZxqRY179JI2EAPM4P
ojR8YuTmFDEPgz+4Ae4IUIJyhJBean5D/CFy3TpHYTUlK3eA1cH7PDNOW7oTGSmM
+zRkD1HnkaPVwylmNvI4RmceA0JuhCi9Y35Bkxa1yBLLB+uRC1Zf4+Ek/QCg/4Jh
161Ewn5UOV2eAmxFFRmyCLsD/jCeNrU4w5i/8YLoVFy3vZYhNsPL299vNc/PmF+h
+NPbb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79jQKqfllZshrs01PpB1UvG77Rn/I
zadbj29gIFw1Gt2eh5aRIN0F2QxvqeMvZ6APqjutv4i+tm1L3U8JNW8fsCpCKkI6
h6MBJSaW6GWTtCBGA/5IX35cg5HlpbwZw96Y892JAEwEGBECAAwFAkAvrCkFGwwA
AAAACgkQ4RXc3SiZNM/0VACeORa/zYtGyekOwxUXzW5BQqdlsjIAoPhHLTE5Kwcq
2WgOOCUuqD0QoU8e
=/4Ed
-----END PGP PUBLIC KEY BLOCK-----
_______________________________________________
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.