Keychain
public class Keychain
This class offers an interface to the Keychain services.
They Keychain basically is a collection of items with attributes. Some attributes are stored securely and require user authorization to be accessed.
-
Defines errors that might occur during interaction with the systems Keychain service.
See moreDeclaration
Swift
public enum Error : Swift.Error -
Adds a new generic password to the Keychain.
If the item already exists the
itemAlreadyExistserror will be thrown.Declaration
Swift
public static func store(password: Data, in item: GenericPasswordItem, with label: String? = nil) throwsParameters
passwordThe actual password that should be stored securely.
itemThe item that should contain the password.
labelA label for the item.
-
Adds a new generic password to the Keychain.
If the item already exists the
itemAlreadyExistserror will be thrown.Declaration
Swift
public static func store(password: String, in item: GenericPasswordItem, with label: String? = nil) throwsParameters
passwordThe actual password that should be stored securely.
itemThe item that should contain the password.
labelA label for the item.
-
Updates the generic password for a given item.
Declaration
Swift
public static func update(password: Data, for item: GenericPasswordItem) throwsParameters
passwordThe new password.
itemThe item, that should be updated.
-
Updates the generic password for a given item.
Declaration
Swift
public static func update(password: String, for item: GenericPasswordItem) throwsParameters
passwordThe new password.
itemThe item, that should be updated.
-
Convenience function that updates the password if it exists or creates it otherwise.
Declaration
Swift
public static func updateOrCreate(password: Data, for item: GenericPasswordItem) throwsParameters
passwordThe new password.
itemThe item, that should be updated or created.
-
Convenience function that updates the password if it exists or creates it otherwise.
Declaration
Swift
public static func updateOrCreate(password: String, for item: GenericPasswordItem) throwsParameters
passwordThe new password.
itemThe item, that should be updated or created.
-
Retrieve a generic password for a given item.
Declaration
Swift
public static func retrievePassword(for item: GenericPasswordItem) throws -> DataParameters
itemThe item, for which the password should be retrieved.
Return Value
The password stored for the given item.
-
Retrieve a generic password for a given item.
Declaration
Swift
public static func retrievePassword(for item: GenericPasswordItem) throws -> String?Parameters
itemThe item, for which the password should be retrieved.
Return Value
The password stored for the given item.
-
Removes an item from the Keychain.
Declaration
Swift
public static func delete(item: KeychainItem) throwsParameters
itemThe item that should be removed.
View on GitHub
Keychain Class Reference