Data Saving

Discussion in 'iOS Programming' started by Mvkoe, Jan 13, 2013.

  1. Mvkoe macrumors member

    Mvkoe

    Joined:
    Aug 4, 2008
    Location:
    Belgium
    #1
    Hey

    I'm a bit lost in the dark. I'm saving my data with plist files, I'm using like 4 plist files for handeling my data atm, this is getting a bit confusing and maybe slow.

    So I was wondering what is the best way to save data? Core data, SQL, or still plists ? My data consists of things that users can add and modify and play with.

    I tried to have a look at Core data, but this is a bit "confusing" and can't seem to find a start at it.

    Grz
     
  2. Albright macrumors regular

    Joined:
    Aug 23, 2011
    #2
    It can be hard to tell what would be best for you to use without knowing more about your use case, but from what I understand, it looks like this:

    Plists: Simplest approach to saving and loading data. Fine for when reading and writing an entire file/blob of data in one operation is no problem. No way to do queries on the data without loading the entire file into memory first. No way to do complex relationships.

    Core Data: When you want a more database-like approach, where you can do "inserts" and "queries" on the data without having to read or write the entire dataset. Database-like functionality, but with the database guts abstracted away (from what I understand, though in practice the database at the bottom of it all will be SQLite, it's possible to swap that out for some other form of data storage but still have it all be accessible through the Core Data API).

    Directly manipulating SQLite files: For when speed is absolutely essential and you want to avoid the overhead of Core Data's API. However, you sacrifice niceties like having the results already turned into NSManagedObjects and such.

    If plists aren't cutting it, I'd give Core Data a try; it's well-supported in the ecosystem and odds are it will be plenty fast for your needs. Like any big new API, there will be a lot to learn; Hillegass's "iOS Programming" has a section on it which doesn't go into a lot of detail, but was enough to get me started using it on a project I'm working on now.
     
  3. KoolStar macrumors demi-god

    KoolStar

    Joined:
    Oct 16, 2006
    Location:
    Kentucky
    #3
    I would second this, if you do not totally get core data but do understand sqlite there is a good sqlite wrapper for iOS called FMDB (Link)
     

Share This Page