Is there an ORM framework for Cocoa, or a framework that accomplishes a similar goal using a different technique?

后端 未结 4 541
执笔经年
执笔经年 2021-01-20 05:19

I\'m developing an application that needs to store lots of records in an organized way. Specifically, I\'m writing a personal finance app. As you can imagine, this app will

4条回答
  •  自闭症患者
    2021-01-20 05:31

    The closest thing to an ORM that ships with Cocoa is CoreData. It's not quiet an ORM though, but more an in memory object graph that can be serialized to disk.

    It uses a general Model based layout and you can add helper functions and the like to said models. It can maintain referential integrity and the like as well, and requires no SQL to be used.

    It can have one of three storage backends, the recommended one being SQLLite. I almosted used it for my current app. However, I found after testing a while with it that it was too heavy. This is supposed to be much better off in 10.5+, however I'm targeting 10.4 and I just found it to be too memory hungry/slow for my uses.

    As far as querying it, you do most (all?) queries via NSPredicates, and then you can use a foreignKey style construct to access related models. It can be quiet useful.

    Is it as full featured as ActiveRecord, Django's ORM, or SQLAlchemy? No. But it's pretty good.

    I'd recommend prototyping with it and trying to see how it works out for you. For further reading, I'd recommend the Core Data Book from the Pragmatic Bookshelf. I've read it and found it in general to be very helpful in understanding Core Data.

提交回复
热议问题