title: IOS UserDefault cannot be stored locally
body: <p>I am new to programming and I am now working on an app that requires a login system. (A not so secure system). I wrote the following codes </p>
  
  <pre><code>@IBAction func CreateACPressed(_ sender: Any) {
      if usernameTextField2.hasText &amp;&amp; passswordTExtField2.hasText {
  
    let  newUser = accountInfo(username: usernameTextField2.text!, password: passswordTExtField2.text!)
  
  
      var randomTestingArr : NSArray = [accountInfo]() as NSArray
  
      randomTestingArr.adding(newUser)
  
     let defaults = UserDefaults.standard
     defaults.set(randomTestingArr, forKey: "ACArr")
     defaults.synchronize()
  
     let array = defaults.array(forKey: "ACArr")  as? [accountInfo] ?? [accountInfo]()
  
      for i in array{
          print("username: \(i.username) password: \(i.password)")
      }
  
  
  
      // temp retrieve
      }else {
          print("you havent entered anything")
      }
  
  }
  </code></pre>
  
  <p>but when I hit the create button on my app, the console did not print out the username and password I entered. </p>
  
  <p>what is the problem here?</p>