S
S
Stanislav Korolevskiy2015-10-22 09:47:58
Swift
Stanislav Korolevskiy, 2015-10-22 09:47:58

How to save the user's entered data in the TextField by pressing the "done" key on the keyboard?

Good day everyone! Tell me how to teach the application to remember the user's entered data in the TextField field by pressing the "done" key on the keyboard? There are several TextField and ImageView (the user in the album selects a photo and makes a descriptive part).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Korolevskiy, 2015-10-22
@korolevsky_s

If anyone is interested, here is the solution!

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var Name: UITextField!
    let saveName = NSUserDefaults.standardUserDefaults()
    @IBAction func HideKeyboardName(sender: UITextField) {
        saveName.setObject(Name.text, forKey: "Name")
    }

override func viewDidLoad() {
        super.viewDidLoad()
        
        if let text = saveName.stringForKey("Name") {
            Name.text = text
        }

        }
}

A
AmikoYuki, 2015-10-22
@AmikoYuki

stackoverflow.com/questions/2137644/save-the-curre...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question