1

I'm looking to build a reporting system, it will have canned reports, and user created reports, for each report I'll need the name, description, and the information that it will contain below is a structure I've jsonlint'ed to represent all the data a single report called "Review Progress" (inside the canned report structure) will need.

{
"Canned": [
    {
        "Name": "Review Progress",
        "Description": "Quick Look at ...",
        "Contents": {
            "Collections": [],
            "Filters": [],
            "Facets": {
                "Review Status": [
                    {
                        "Reviewed": {
                            "value": "300",
                            "enabled": "true"
                        }
                    },
                    {
                        "Not Reviewed": {
                            "value": "150",
                            "enabled": "false"
                        }
                    }
                ]
            }
        }
    }
]

}

Am I barking up the wrong tree here by creating a series of dictionaries and arrays as accessing items inside of it for setting up the tableview will start to look something like this?

cell.textLabel.text = self.reports[indexPath.section][@"Reports"][indexPath.row][@"Name"];

Would anyone suggest a different approach like coredata/some sort of DB instead for ease? I ask as users will be able to create their own reports which will have to have the same data.

Stu P.
  • 1,365
  • 1
  • 14
  • 31
  • I say .plist is fine, even `NSUserDefaults` would work. With the .plist, you could put in Documents folder and enable iCloud sync. – Marcus Adams Aug 23 '13 at 17:11
  • It depends on what you intend to do with the data. A larger data set and/or complex operations (sorting, filtering, adding deleting, editing, etc.) would probably fit core data better. This answer has some good guidelines: http://stackoverflow.com/a/1883957/620197 – Mike D Aug 23 '13 at 17:33

1 Answers1

2

A quick way should be to use JSON Accelerator (free) to generate object models form your JSON.

And then add to your "top" generated class model the category provided by this repository:

https://github.com/psineur/NSObject-AutomagicCoding

to easily load/save the dictionary representation (i.e. plist/json structured data) to the document folder

This will be quite the same than

cell.textLabel.text = self.reports[indexPath.section][@"Reports"][indexPath.row][@"Name"];

But more cleaner in my opinion thanks to object models

Alban
  • 1,624
  • 11
  • 21