开发者

Cocoa way to represent data for iphone dev

开发者 https://www.devze.com 2023-01-17 01:07 出处:网络
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).

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 iPh开发者_如何学编程one 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消