title: Update only one of two UITextFields stored in userData in Swift 5.3
body: <p>Using UserDefaults to store two user input fields to be used throughout various VCs.  UILabels show the current settings, while UITextFields accept updated input.  I can set, store, display and update the two fields, but updates have to be in tandem.  I cannot figure out the proper method to update only one of the two fields.  As an example, update the email only, without touching &quot;evernote&quot; in my case.  Without the work around below, and when only inputting one of two fields, the second non-input field is overridden as blank.</p>
  <p>As a work around, I include the saved data as the initial input for the two UITextFields.  Code works, just does not seem to be optimal.  Ideally the two UITextFields would not have initial values.  I have mucked around with != null statements in the button function, but to no avail.</p>
  <p>Any advice would be greatly appreciated, and thank you in advance.</p>
  <p>Class to share userData input among VCs:</p>
  <p>class UDM {</p>
  <pre><code>static let shared = UDM()
  let userData = UserDefaults(suiteName: &quot;xxxx.saved.data&quot;)!
  </code></pre>
  <p>}</p>
  <p>Outlets and Actions:</p>
  <pre><code>@IBOutlet weak var emailLabel: UILabel!
  @IBOutlet weak var evernoteLabel: UILabel!
  
  @IBOutlet weak var enterEmail: UITextField?
  @IBOutlet weak var enterEvernote: UITextField?
  
  @IBAction func saveButton(_ sender: UIButton) {
      UDM.shared.userData.set(enterEmail?.text, forKey: &quot;email&quot;)
      UDM.shared.userData.set(enterEvernote?.text, forKey: &quot;evernote&quot;)
  }
  </code></pre>
  <p>viewDidLoad UI:</p>
  <pre><code>    let emailObject = UDM.shared.userData.object(forKey: &quot;email&quot;)
      if let email = emailObject as? String {
          enterEmail?.text = email
          emailLabel.text = email
      }
      
      let evernoteObject = UDM.shared.userData.object(forKey: &quot;evernote&quot;)
      if let evernote = evernoteObject as? String {
          enterEvernote?.text = evernote
          evernoteLabel.text = evernote
      }
  </code></pre>