Oren Edrich Oren Edrich - 1 year ago 128
iOS Question

Save UIButton state

class GameViewController: UIViewController, UIPopoverPresentationControllerDelegate {

@IBOutlet weak var instructions: UIButton!

@IBAction func instructions(_ sender: AnyObject) {
instructions.isHidden = true


This is my code to display instructions on how to use the app.
I currently have an image-button and when I click on it the image disappears. This works great but I don't want the instructions to pop up overtime someone opens the app. I want to use "Userdefaults" to save the state of the button.
I just recently updated to swift 3.0 and I can't find anyone who explains how to it, please help!

Answer Source
UserDefaults.standard().set("True", forKey: "isHidden")

print("\(UserDefaults.standard.value(forKey: "isHidden")!)")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download