Latch

public struct Latch

Latch is a simple abstraction around the iOS and OS X keychain API. Multiple Latch instances can use the same service, accessGroup, and accessibility attributes.

  • Create a new instance of Latch with a service, accessGroup, and accessibility.

    :param: service The keychain access service to use for records. :param: accessGroup The keychain access group to use - ignored on the iOS simulator. :param: accessibility The accessibility class to use for records.

    :returns: An instance of Latch.

    Declaration

    Swift

    public init(service: String, accessGroup: String? = nil, accessibility: LatchAccessibility = .AfterFirstUnlockThisDeviceOnly)
  • Retreives the data for a given key, or returns nil.

    Declaration

    Swift

    public func dataForKey(key: String) -> NSData?
  • Retreives the string value for a given key. It will return nil if the data is not a UTF8 encoded string.

    Declaration

    Swift

    public func stringForKey(key: String) -> String?
  • Set a string value for a given key.

    Declaration

    Swift

    public func setObject(object: String, forKey key: String) -> Bool
  • Set an NSCoding compliant object for a given key.

    Declaration

    Swift

    public func setObject(object: NSCoding, forKey key: String) -> Bool
  • Set an NSData blob for a given key.

    Declaration

    Swift

    public func setObject(object: NSData, forKey key: String) -> Bool
  • Remove an object from the keychain for a given key.

    Declaration

    Swift

    public func removeObjectForKey(key: String) -> Bool
  • Remove all objects from the keychain for the current app. Only available on iOS and watchOS.

    Declaration

    Swift

    public func resetKeychain() -> Bool