views:

324

answers:

5

I'm creating an iPhone app and I'm trying to choose between 2 solutions for a persistent store.

Core Data, or SQLitePersistentObjects. Basically, all my app needs is a way to store an array of model objects and then load them again to display in a UITableView. Its nothing too complicated. Core Data seems to have a much higher learning curve than the simple to use SQLitePersistentObjects. Are there any obvious benefits of using Core Data over SQLitePersistentObjects in my case?

+1  A: 

See this question. My answer to that question also applies to yours.

http://stackoverflow.com/questions/2289102/core-data-vs-sql-statement-which-one-is-gd-for-iphone-development/2290438

Marcus S. Zarra
it doesn't because SQLitePersistentObjects is an ORM.
sbwoodside
It is because you should be using Apple tech for this, that is why they wrote Core Data. It is worth the OPs time to research Core Data and understand the technology.
Marcus S. Zarra
Your answer compares using bare SQLite to using Core Data. That's an incorrect comparison. SQLPO != bare SQLite. I agree that researching Core Data is fine, but alternatives should not be dismissed out of hand. Core Data is an example of a darker moment for apple API design. Compare it to ActiveRecord in rails and other nice ORMs...
sbwoodside
A: 

I recently had to make the same decision. I was storing instances of a simple object with a couple of properties. From my research I understand that using Core Data will help you better manage more complex objects with multiple relationships. I ended up using Core Data only because I wanted to learn more about it (but for simple objects there wasn't much of a learning curve).

cagreen
A: 

SQLitePersistentObjects aka SQLLite Persistent Objects is not the same as doing straight SQLite at all. It's an ORM in its own right. I haven't used it yet, but I wanted to correct the completely wrong answer that the previous poster gave.

And I'm seriously considering using because Core Data is a pain.

See: http://iphonedevelopment.blogspot.com/2008/08/sqlite-persistent-objects.html

sbwoodside
Which previous answer? Right now the one above you is the guy who wrote SQLPO, I doubt that is who you meant though, more likely SO just rearranged the answers. Could you specify?
Alex Gosselin
Based on the dates I must have been referring to the answer by Marcus S. Zarra. I realize that using Core Data is gospel but it still is full of bugs and annoying things that anyone who's used, for example, ActiveRecord will hate. No one wants to hear this, but be warned.
sbwoodside
+3  A: 

As the author of SQLite Persistent Objects, I say: use Core Data.

I wrote SQLPO when Core Data didn't exist on the phone. Although I'm proud of what I did with SQLPO and even though I do like some things about its approach better than Core Data's (specifically not having to maintain separate class files and data model), the engine underlying Core Data is much more mature and has many more engineering hours invested in it. That's why I abandoned SQLPO development when Core Data came to the iPhone SDK.

I haven't done benchmarks, but I would guess that used correctly, Core Data is going to perform better in nearly all high-volume situations.

SQLPO is faster to develop with since all you do is create the header files, but unless your data needs are relatively light, I say you'd be better off using Core Data.

Jeff LaMarche
Jeff, it's too bad you've given it up, because what the platform really needs is a great ORM that isn't Core Data.
sbwoodside
+1  A: 

Some infromation on my experience with SQLitePersistentObjects.

An app initially developed for iOS 3.x utilizing SQLPO works just fine. Easy to use etc. Now I am in the process of bringing this app to iOS 4 and things started to get strange.

I now see DB corruptions at unpredictable rates.

Looking into the SQLPO code shows that there is only one sqlite3_close statement and this is called when the DB can not be opened.

I am planning to add a method to close the DB explicitely and call this from my app delegates terminate and for iOS4 didMovetoBackground methods. Might help to avoid DB corruption issues with SQLPO.

karl