views:

49

answers:

2

Is Core Data still a good option to use for the iOS even if they data will only be quite temporary. i.e – data being sent up to a server in the cloud once within range of a network, and then never needed again on the mobile device.

A: 

Yes, if there could ever be a large number of records (e.g. user is overseas, doesn't have a data connection), use Core Data. The point of the Core Data abstraction is just this - if you only have 10 records max, ever, it may just use a flat file of data, or maybe a Sqlite database if more than that -- by "handing the problem" over to Core Data, you make storage decisions Apple's problem, and for free you'll get all the optimizations that Apple'll throw into the Core Data framework in the coming years.

Core Data is complex when you first look at it. Apple's API docs aren't bad, but there are a few "gotchas". If you've worked with anything like the Entity ORM framework, etc, it's really easy to pick up.

Alternatively, if you're reasonably certain that you're only going to get 5-10 records, and the data is anything that conforms to NSCoder, you could just archive it and save it, and then unarchive it when you launch the app. Also, if it's array data, a plist is pretty nice.

phooze
Core Data is not a database abstraction layer. It is an object hierarchy that happens to persist to disk. Looking at it as a DRM layer is the cause of most people's confusion with regard to Core Data. In addition, Core Data can be used for any number of objects, 1 to N with the same level of complexity. It is a superior option over flat files in every situation.
Marcus S. Zarra
Marcus, you're absolutely correct. It's an ORM, not a DRM.
phooze
+1  A: 

You don't have to use Core Data to persist data.

If you don't want to persist the data at all, you can define an in-memory store which never writes to disk.

Core Data's true function is the management of an object graph i.e. it handles the relationships between objects. It's real advantage is the ability to automatically handle complexity.

That complexity can arise from the data objects themselves or from their needed relationships to controller or view objects. Either way, Core Data makes it easy to tie all the objects together without great gobs of custom code. Where the objects end up being persisted or even persisted at all, is really secondary.

TechZen