I used both options in a large number of projects.
FMDB is very simple, if you know SQL, it can even be quite easy to use. But what you have to do through the application life cycle is how to change the data model:
- Change the data model, usually with something like Base
- Modify the SQL code to reflect model changes.
- Modify data objects to reflect model changes.
- Add code to the application to handle the case when you encounter older databases.
What basic data lead to a life cycle:
- The data model and objects change with the same action (I'm assuming you are creating data objects with something like a mogenerator ).
- Simple visualization of the data model.
- Encourages easier relocation of data models, making you think about inverse relationships.
- Often, automatic migration is enough to go through a simple change model without having to rebuild the database from scratch.
- Core Data offers some iCloud integration through NSManagedDocument.
Damn that Core Data puts you through:
- Deletion sucks because any access to properties in the remote object throws an exception to exclude the program.
- Access to data with background threads sucks because Core Data makes it complex to work correctly with multiple threads โ you cannot, for example, use a data object obtained from the context in one thread in another thread. So much for simple passing objects background threads to work with ...
- There is so much magic in your data that WHEN everything goes wrong, it will be terribly frustrating, trying to figure out what to do.
- The basic data seems terribly fragile: everything related to exceptions of excluded objects, the use of incorrect exceptions from a stream, exceptions to exclude exceptions, or a complete model disappearing after what seemed like a simple change are all possibilities.
So what would I recommend? To paraphrase an old quote about democracy, Core Data is the worst data storage system - with the exception of everyone else. Even with the new definition of pain and suffering that Core Data brings to your life, working and working is still easier than FMDB or other levels of data storage.
FMDB is simpler, and if you're fine, add a lot of time to change and define a data model, which might be fine. But overall, I would recommend people bite a bullet and use Core Data if there is no clear reason not to.
A few quick tips:
- Never delete anything in Core Data while the user interface is down and possibly access to objects.
- If it is possible to consider the database as one-time and be able to rebuild the content, so if the automation does not work, the user can still run the application.
- Keep the activity of the master data in the main stream and add only the background as a last resort.
- Under no circumstances should you use master data validations or never clear the "optional" fore field in your entities. Which would you prefer, a bad value gliding across your model that might seem funny or the app just crashes?
- Use mogenerator to create data objects from your model. It displays objects that are directly attached to the model that the generation can change, and a layer of objects of the "above" type, which starts empty, but into which you can add your own logic around data objects and will not be changed when restoring lower objects.
Kendall helmstetter gelner
source share