NSUserDefaults vs sqlite3

后端 未结 2 1916
春和景丽
春和景丽 2021-01-15 09:13

I have a small iPhone app that stores a list of objects. The user can add and remove objects, but this list will remain fairly small (most users would have 10-30 objects). <

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-15 09:51

    NSUserDefaults is for user preferences, usually basic objects like NSString or NSNumber. Sqlite, serializing a collection of objects in a property list, or Core Data are all valid options for storing user data such as model objects you created.

    You're not going to see a speed difference, but it's still best to pick the correct mechanism for what you're doing. If it's just preferences then use NSUserDefaults, otherwise I would serialize your objects to a plist. If you're new to Cocoa I would avoid Core Data and even sqlite at first, to give yourself a chance to learn the basics first.

提交回复
热议问题