title: iOS Keychain won't add queries with hardcoded strings
body: <p>I am following the Apple documentation for adding a password to the keychain located here -> <a href="https://developer.apple.com/documentation/security/keychain_services/keychain_items/adding_a_password_to_the_keychain" rel="nofollow noreferrer">https://developer.apple.com/documentation/security/keychain_services/keychain_items/adding_a_password_to_the_keychain</a></p>
  
  <p>When I run the following code it works as expected and the status comes back as 0.</p>
  
  <pre><code>        let credentials = Credentials(username: "testUserName", password: "testPassword")
          let server = "www.example.com"
          let account = credentials.username
          let password = credentials.password.data(using: String.Encoding.utf8)!
          let query: [String: Any] = [kSecClass as String: kSecClassInternetPassword,
                                      kSecAttrAccount as String: account,
                                      kSecAttrServer as String: server,
                                      kSecValueData as String: password]
  
          let status = SecItemAdd(query as CFDictionary, nil)
          print(status)
  </code></pre>
  
  <p>When I modify the code with hardcoded strings it fails with a status of -50.</p>
  
  <pre><code>        let credentials = Credentials(username: "testUserName", password: "testPassword")
          let server = "www.example.com"
          //let account = credentials.username
          //let password = credentials.password.data(using: String.Encoding.utf8)!
          let account = "testUserName"
          let password = "testPassword"
          let query: [String: Any] = [kSecClass as String: kSecClassInternetPassword,
                                      kSecAttrAccount as String: account,
                                      kSecAttrServer as String: server,
                                      kSecValueData as String: password]
  
          let status = SecItemAdd(query as CFDictionary, nil)
          print("Keychain Save Status: \(status)")
  </code></pre>
  
  <p>Can someone explain this to me? I also tried explicitly setting the strings to utf8 format with <code>let account = "testUsername".utf8</code>. It doesn't make sense to me that this would fail if the value is a valid string.</p>
  
  <p>Also does anyone have the link to the status code descriptions? I found the descriptions but it doesn't give the associated number code <a href="https://developer.apple.com/documentation/security/1542001-security_framework_result_codes" rel="nofollow noreferrer">https://developer.apple.com/documentation/security/1542001-security_framework_result_codes</a></p>