would you store this [data, ints, birthday, blah, blah, blah] in SwiftData or just use the document directory for the whole thing?
I wouldn't use SwiftData
unless you have a number of records with a similar structure. Your use cases point to a single object with many parameters. Yet for other reasons, it's not benficial to store this in UserDefaults
.
One option for you to consider, save the user's data in a single JSON
file. @twoStraws has a number of lessons on this excellent site where he reads, modifies, and stores an json file to a user's device. This solution seems well suited for your needs.
Sensitive Data
But what about the sensitive data?
First, I'd worry about getting the data into json
and saving it, modifying it, then storing it back again to the user's drive.
After this is working great, you might consider looking into Apple's CryptoKit
library.
See -> CryptoKit
But this might be overkill?
Take a look at this article on Apple's site on file encryption at rest. While a file is written to your device, it can be encrypted. It stays encrypted until you unlock your iPhone or iPad. Maybe this is what you really want?
See -> Encrypted at Rest
Keep Coding!
Please return here and let us know what path you selected. And share your advice and code!