views:

50

answers:

1

I have a string of data in a plist, which I've got to display, hierarchically like this:

Menu>Chapter>SubChapter>item>item details

This might be super simple, in my initial menu, how would I have all 'All' Menu item to display all the 'items', essentially skipping the chapter and subchapter and cutting out that aspect of my filter, while retaining the other chapter and subchapter aspects.

I could do it by doubling up the data of all items wherever I wanted them to appear, but this seemed very inefficient.

or

Would it be easier to parse data into a core data entity to do this?

+2  A: 

CoreData could simplify your code much, especially if you often have to add, remove or modify objects. Then you could retrieve the items in a single fetch request, which is quite efficient.

On the other hand, if you only use more or less static data, then the overhead you generate with CoreData (ManagedObjectContext, PersistentStoreCoordinator, etc.) might not pay out and you would best just after parsing the plist to create an array holding all items, like this:

NSMutableArray* allItems = [NSMutableArray array];
for (NSArray* chapter in menu) {
    for (NSArray* subchapter in chapter) {
        for (id item in subchapter) {
            [allItems addObject:item];
        }
    }
}
frenetisch applaudierend