Successfully stored String value to keychain, but always failed to read it out
问题 I am developing an iOS project with XCode8 + Swift3. I have created the following two functions to store string to keychain and read it back from keychain: var query: [String: Any] = [ kSecClass as String: kSecClassGenericPassword, kSecAttrService as String: "my service", kSecAttrAccount as String: "my-key" ] func storeString(value: String) -> Bool { if let data = value.data(using: .utf8) { // delete data if exist SecItemDelete(query as CFDictionary) // add value to query query[kSecValueData