How can I store most-effectively user input data on SwiftUI? [closed]

I am building an app in SwiftUI which is a more-in-depth version of "Notes". The plan is that the user can create groups and inside of it specific notes with images, links etc. you know it. I am wondering what the perfect/ most efficient type of storage would be. The user inputs should only be able to access the data through his device.

Is Realm/ Firebase necessary? Is UserDefault/ another SwiftUI function enough to store different inputs/ images etc?

Thanks in Advance!


Solution 1:

UserDefaults is great for small pieces of data - like settings. It loads when the app loads and is fast to access. You can also easily synchronize it with iCloud via NSUbiquitousKeyValueStore - and you will not lose the ability to transfer the app to another account that you otherwise would with using CloudKit.

However, in your use, UserDefaults will probably not be an ideal solution for saving the data. First, you would like to probably have some relationship between several pieces of data - much simpler with Realm or Core Data. Also, with lots of notes, you wouldn’t want to load every note on app startup. It would be too slow. With UserDefaults, it would be much harder to migrate data, etc.

Apple used to have a limit on the size of UserDefaults, it’s gone now and remains only for TV app (1MB and the app is terminated), but I’d recommend to think about the limit when you model the app so the performance would not hinder.