Working with data in iOS Apps (What to choose? NSData, CoreData, sqlite, PList, NSUserDefaults)

前端 未结 2 601
名媛妹妹
名媛妹妹 2020-11-27 17:21

when I develop an iPhone App (Time Tracker, ToDoList etc) I never know whats the best way to deal with the data. Once I used a plist, next time sqlite or CoreData.

H

2条回答
  •  野性不改
    2020-11-27 17:48

    My rule of thumb for each of those would be:

    • Time Tracker App > Core Data
    • RSS Reader App > Core Data
    • Photo App > Core Data
    • EMail Client > Core Data

    Though in each case there would be things you would store on the file system. For instance, the photo app would obviously put the actual photos on the file system. The text of the emails would be on the file system etc. The actual RSS messages might be text files too, but with meta data in Core Data objects.

    At some point, you might find that the data you are storing is outgrowing the scalability of Core Data. At that point you would consider moving to SQLite.

    The point is that Core Data is so easy to use and so superior to the alleged lighter weight alternatives, why wouldn't you use it?

提交回复
热议问题