0

iOS has more than one local databases like CoreData, Keychain, UserDefault. All 3 databases do the same thing, Saving, Updating, Selecting, etc. Are there any different between them, like security, memory or speed? When using (CoreData, UserDefaults, Keychain) more powerful than others?

jscs
  • 63,694
  • 13
  • 151
  • 195
Omer Tekbiyik
  • 4,255
  • 1
  • 15
  • 27
  • 1
    Each have completely different uses. Please read the documentation for each and then update your question with more details about what you need clarified. – rmaddy Jan 25 '19 at 22:57

2 Answers2

6

Not everything , but in short

  • Userdefaults : is used for saving settings data. It's not to be used for temporary data across viewControllers. It's the fastest as it's plist file or a dictionary when it comes to running state of the app

  • CoreData : is a relational database used for large data storage , creates models automatically from simple UI and it's a sqlite-based

  • Keychain : is the most secure and always used for sensitive data like tokens , passwords etc. But it's also the slowest one as it's a c - wrapper.
mfaani
  • 33,269
  • 19
  • 164
  • 293
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
1

NSCoding/NSKeyed​Archiver vs. Core Data doesn't directly answer your question. But it's very helpful. Long story short: Core data is a pain in the neck but when it comes to modeling, querying, traversing and persisting complex object graphs, there is no substitute for Core Data. Core Data is a big hammer, but not every problem is a nail—much less a sufficiently large nail.

KeyChain is more like a vault. You store small limited information in it e.g. password. You don't store the entire database in it. It acts like a gatekeeper "Can this user open the app? Yes? Ok let's open up our data base and show core data entries..."

UserDefaults are like the last page a user was at. You may store a single custom object, but don't store a big record of it.

mfaani
  • 33,269
  • 19
  • 164
  • 293