UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Where to store User's data (date of birth, weight, etc...) between more devices.

Forums > Swift

Hello, I am building an app for drink reminding. I struggle where to store user's data. I would like to use CloudKit for sharing between devices but is it OK? For example, if an iPad doesn't have internet I don't get data so I create new data and post it to the CloudKit then there would be data from iPhone and iPad? The easiest way is to use UserDefaults but it is not synchronized between devices right? I need to share data between iPhone, iPad, Watch

2      

From Hacking with Swift Plus Storing preferance efficiently.

goto to "Signing & Capabilities" . Add new "App Groups" with group.(reserve domain name)

extension UserDefaults {
    static var shared: UserDefaults {
        guard let defaults = UserDefaults(suiteName: "group.co.uk.theappforest.UserDefaultsExample") else {
            return UserDefaults.standard
        }
        return defaults
    }
}

then you can use

UserDefaults.shared.set("nigel", forKey: "UserName")
UserDefaults.shared.set(true, forKey: "isActive")

ETC

There is a lot more but that the basic. It worth subscribing to HWS+

2      

Hacking with Swift is sponsored by RevenueCat

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.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

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.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.