0

I'm trying to setup a alert view that the user will type their salary into a text-field in the alert view, and then the NSUserdefault will update when the user clicks the done button. I'm getting an error when putting the code in the completion block.

var alertAction = UIAlertAction(
    title: "Done", 
    style: UIAlertActionStyle.Default, 
    handler: { (action) -> Void in
        userDefaults.setValue(value: (altMessage.textFields![0] as! UITextField).text, forKey: "salary")
    }
)
Jota
  • 17,281
  • 7
  • 63
  • 93
user3275730
  • 25
  • 1
  • 6

1 Answers1

1
userDefaults.setValue(value:

No. That's not Swift. Delete that second value:, like this:

userDefaults.setValue(
matt
  • 515,959
  • 87
  • 875
  • 1,141