Defaults Set and get value for Boolean Type in Swift 3

User defaults are used to store the data with key values inside of the app memory and get that in entire app classes.You can store by key value and also access by key value.

Defaults set value using Below code


        let defaults = UserDefaults.standard
        defaults.set(true, forKey: "Key")

        defaults.synchronize()


Defaults Get value using Below code


        let value = defaults.value(forKey: "isInitial") as! Bool



Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Saved Image in document directory and save path in coredata not able to fetch the image file iOS swift