Making an iOS application is all fun until you have to start maintaining offline user sessions and preferences on the app. Then comes the age old question.
Core Data/SQLite or something else?
So I want to share some of my insights on the topic.
Let’s start with Core Data,
- Graph framework for maintaining objects and their relationships with each other.
- Stores its data into a SQLite DB but is not a database in itself.
- Manages and updates objects automatically in the memory. Can handle a complex graph of objects without any pressure/load on the memory management system of the device.
- Has object versioning system in place which lets you update the object entities and attributes without deleting the previous data.
- Is an Apple created framework, so is automatically updated with any updates in Swift. And now for SQLite,
SQLite is a persistent database model, which make a database and stores it in the file management system of your phone’s application.
- It could be used for more lightweight models since its memory management will be dependent on the CocoaPods or Frameworks that have been used.
- SQLite Pods or third party providers are easier to use and easier to grasp.
- Can be created and updated just by writing a few custom queries. There are many Pods for SQLite in the market but one of the most popular and most stable is SQLite3.
There are pros and cons to both the frameworks and it all depends upon your requirements.
If you have enough time to configure a data persistence system, do dig into the Core Data option too.
There is another newer and faster option on the internet called Realm. I can’t really comment on it since I haven’t worked with it. It supports most platforms like Android, Swift, ObjC as well as React Native.
Since there are not many Getting Started with Core Data tutorials that I have come across, So I will be making one myself!