Adding Items to and Querying the iOS Keychain with Swift

前端 未结 5 1791
遇见更好的自我
遇见更好的自我 2020-12-25 14:59

I\'m having trouble converting all of the Objective C code samples that are available for adding data and querying data from the iOS Keychain into

5条回答
  •  既然无缘
    2020-12-25 15:08

    For Swift users

    Single line code to add/retrieve/update fields in Keychain:
    https://github.com/jrendel/SwiftKeychainWrapper

    Usage

    Add a string value to keychain:

    let saveSuccessful: Bool = KeychainWrapper.setString("Some String", forKey: "myKey")  
    

    Retrieve a string value from keychain:

    let retrievedString: String? = KeychainWrapper.stringForKey("myKey")
    

    Remove a string value from keychain:

    let removeSuccessful: Bool = KeychainWrapper.removeObjectForKey("myKey")
    

提交回复
热议问题