Is it okay to put endless data into UserDefaults?I'm not sure if I should switch to Sqlite or Realm.
It would be better to centralize the database, but it would be troublesome if it were an existing application.I use it because it's convenient, but of course, if I put it in endlessly, I think it will be ruined somewhere.
I would like to confirm the following two points.
Please let me know if there are any anti-patterns if you put a large amount of data in UserDefaults and reject it.
Currently, my app contains serialized object data (list data), image objects, etc.
Can I put endless data into UserDefaults?
It's not good.
I can't decide whether to switch to Sqlite or Realm.
Why doesn't it contain Core Data that can be used in iOS standards?By the way, using SQLite directly from the code is not recommended because it is not productive and buggy.
Apple documents include:
Currently, there is only a size limit for data stored to local user defaults on tvOS, which posts a warning notification when user defaults storage reach 512kBin size, and terminals apps when user defaults storage reach 1MB in size.
(Currently, only tvOS has a size limit.)
Increased capacity can cause frequent errors, slow loading and writing.
In the case of this article, it says, "It takes a long time to process, so I killed the app, and now the app crashes at startup."
For example, there is a blog post that looks at the details of UserDefaults' behavior.
UserDefaults Limitations and Alternatives
(I gave it to you because it is representative and easy to understand, but I think you will find many other similar articles.All the articles I write after looking into them carefully are almost the same content and conclusion.)
There's nothing good about storing a lot of data in UserDefaults.
Please let me know if you have any anti-patterns if you put a large amount of data in UserDefaults.
Putting a lot of data into UserDefaults without having to eat them is a typical anti-pattern.Don't do that with a proper, authentic app, let alone an introductory programming article for beginners.
The blog post above summarizes when to use UserDefaults as follows:
("UserDefaults is good for perpetuating a small amount of data, such as user preference" or "Anything else should be stored in the appropriate directory considering its characteristics")
In the past, Apple's Developer Forums used to receive almost the same response from Apple technicians, but recently I couldn't find the link, perhaps because there are fewer questions that seem to be using UserDefaults inappropriately.
Currently, my app contains serialized object data (list data), image objects, etc.
This is my personal opinion, and it's a criterion for developing apps that I can separate, but
Yellow cards, data that allows users to store any number of data (like tens of thousands or tens of thousands of data quickly if users continue to use the app for a long time), cannot be included in UserDefaults
Red card, data that grows in size even by just one image will never be included in UserDefaults
It's like that.For your information.
© 2024 OneMinuteCode. All rights reserved.