|
Let's assume I have an array of hair colors:
I want the user to be able to add to that array from a Picker or better said from a menu containing a Picker and a Button which would push a sheet to add a new color. I'm trying to wrap my head around the best way to persist that new color (or the whole array), so I don't just want to be able to pick it once but for as long as the user uses the app. Even better, the then expanded array would sync across devices. Would UserDefaults make sense technically and wouldn't it be too expensive if I had a few more of these pickers in the app? Creating a CoreData Entity on the other hand seems a bit too much to only save an array of haircolors? Does anyone have any tips? Many thanks! |
|
If you are going to eventually sync across devices then you will get involved with CloudKit, which means CoreData is the way forward. Otherwise, if your app will have different settings in separate devices, then UserDefaults or AppStorage is something to consider (which ever makes more sense for your app). As you are HWS+ subscriber, you are probably going through the UlitmatePortfolio tutorials, or can at least look through some of the more relevant ones that suit your use case. |
|
Thanks @Greenamberred. Yeah it's one thing to figure a solution but another to see whether there are any backdraws without plenty years of experience. That's why I was worrying about performance.
I often do just like with other tutorials I went through. Sometimes it's just difficult to find exactly what I'm looking for :-) |
|
Hi Just a couple a things to note
|
|
Thanks @NigelGee. That's helped a lot.
Yeah I see colors were a bad example. For prototyping reasons I had only saved colors as strings.
That's exactly how I do it with other things in the app based off Pauls Ultimate Portfolio tutorial. Again, I didn't think this far with the hair color example.
This was really helpful. I got to admit, though, that I'll have to rewatch the video for a third or maybe even fourth time to fully get everything. But that's a great starting point! Thanks again! |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.