views:

40

answers:

1

I am writing an objective-c model to hold all of the data parsed from an XML connection. I am using an NSURLConnection to download the data asynchronously and it is then passed to the parser. I have done this before, but not with such a large xml file. I would like to garner some opinions on the best way to store the data. Here are some options:

  1. Create a bunch of NSMutableDictionary's that represent the sections in the xml. Then add a key/value to these dictionaries with the child tags.
  2. Create structs to hold the data as such:

    `struct section_one { NSString *string1; NSString *string2; } sectionOne;

The only thing I'm worried about is how to go about managing the memory of the strings inside the struct. Should I copy the strings when I am instantiating them and release each individual string in the dealloc of the Model class.

Overall, I would just like some suggestions as to how to store the data.

A: 

I'd suggest using NSDictionary instances nested inside another NSDictionary (whether these need to mutable or not depends on how you intend to use them, so I won't comment on that). The keys to the top-level dictionary could then be sectionOne, sectionTwo, etc., and their corresponding values would be the nested dictionary instances.

jlehr