Saving contents of UITextFiled to NSUserDefaults
问题 I'm trying to save a textfield and then retrieve it back in the view did load area here is my code: @IBAction func player1button(sender: AnyObject) { NSUserDefaults.standardUserDefaults().setValue(textfield1.text!, forKey:"firstPlayer") } override func viewDidLoad() { super.viewDidLoad() textfield1.text = (NSUserDefaults.standardUserDefaults().valueForKey("firstPlayer") as! String) } I'm getting this error: terminating with uncaught exception of type NSException 回答1: Use stringForKey when