Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DDustiNN

macrumors 68020
Original poster
Jan 27, 2011
2,485
1,371
I am making an app that will basically consist of two views (it's very similar to the Contacts app). The root view is the main list of items. When the user selects an item, they are presented with a detail view for that item. The detail view consists of a categorized list. Each main item will have the same categories, but may have a different number of items.

So say you click on ItemA. ItemA would have 4 "Awesome Things" and 3 "Dumb Things".

Now ItemB may have 5 "Awesome Things" and only 2 "Dumb Things".

I would basically like to check the view... like:

Code:
if (item.name == "ItemA")
{
  NSArray *awesomeThings = initWithObject "Awesome1", "Awesome2", "Awesome3";
  NSArray *dumbThings = "Dumb1", "Dumb1" blah blah blah (I'm ignoring syntax here of course)
}

Then the second view would just populate the categorized cells accordingly.

I prefer everything to be indexed by main item's name, since the names will all be unique and everything is based off that (the left image in the first view's cell, the title of the second view, their subset of items...).

That's the basic idea of what I want to do. Now of course I could do this for every item, but there are like 30 items... and 30 if/else statements seems kind of ridiculous.

All items are just strings, and their sub-items use stringWithFormat (they contain Unicode characters).

What would be the best way to store this data and access it from the view?

Right now I just have random test data in for only a couple items (written using an if statement like above), just to see if the view works fine, which it does.

I'm thinking I should make a class for these items, but I'm still not sure how I'd populate the data other than using 30 if statements. Or the other thing I thought of was making a separate array for each one... I really don't know. :confused::confused::confused:

I hope I explained this well enough, but feel free to ask questions if something is unclear.

Any advice is greatly appreciated!!

Thanks!
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.