views:

35

answers:

1

I come from heavy web application dev background, and having some problems representing my related data structures the right way in iPhone dev (the 'Model' part of MVC).

Lets say I have a data structure which is best represented via JSON like this:

{
    "Beethoven": {
        "description": "Another great composer", 
        "pictures": [
            "pic1", 
            "pic2", 
            "pic3"
        ]
    }, 
    "Mozart": {
        "description": "Great Austrian composer", 
        "pictures": [
            "pic1", 
            "pic2", 
            "pic3"
        ]
    }
}

This works great in Python/Django, but what would be the right approach for iPhone dev?

Eventually this would be stored in a property list (as the data won't too big/complex).

Should I create Composer class to represent top level objects? or some other way?

A: 

You propably want to use CoreData. This framework allows you to create an abstract model of your data, just like for databases, and to use it in your app without writing a single line of code. It also provides independence of your persistent data storage, so you can switch between different types of storage (SQLite, XML...) easily. I quite liked this tutorial but you might also want to check out the official documentation.

Phlibbo
I've considered it, but it seems an overkill for the small amount of data I have (for this specific case). Will take a peek at the docs, though.
Maverick
You are right, its quite big but I also use it for Small amounts of data. Its easy to ignore most of it and I don't think its much of an overhead from a performance Point of view.
Phlibbo
See this post http://inessential.com/2010/02/26/on_switching_away_from_core_data with some thoughts about when to use CoreData — and when not. Summary could be: Always start with CoreData — it will be perfect for 95% of all projects— and later replace it, in case you find out, that u have on of the other 5% of all cases.
vikingosegundo
Thanks guys, I'm convinced now. Going to bite the bullet and learn Core Data.
Maverick