     /**
     Retreives the data for a given key, or returns nil.
     */
-    public func dataForKey(key: String) -> NSData? {
+    public func data(forKey key: String) -> Data? {
         var query = baseQuery(forKey: key)
-        query[kSecMatchLimit as String] = kSecMatchLimitOne as String
-        query[kSecReturnData as String] = true
+        query[kSecMatchLimit] = kSecMatchLimitOne
+        query[kSecReturnData] = true as AnyObject?
 
         var dataRef: CFTypeRef?
-        let status = SecItemCopyMatching(query as CFDictionaryRef, &dataRef)
+        let status = SecItemCopyMatching(query as CFDictionary, &dataRef)
         if status != errSecSuccess && status != errSecItemNotFound {
             print("Latch failed to retrieve data for key '\(key)', error: \(status)")
         }
 
-        return dataRef as? NSData
+        return dataRef as? Data
     }
 
     /**
     Retreives the string value for a given key. It will return nil if the data
     is not a UTF8 encoded string.
     */
-    public func stringForKey(key: String) -> String? {
-        guard let data = dataForKey(key) else { return nil }
-        return NSString(data: data, encoding: NSUTF8StringEncoding) as? String
+    public func string(forKey key: String) -> String? {
+        guard let data = data(forKey: key) else { return nil }
+        return NSString(data: data, encoding: String.Encoding.utf8.rawValue) as? String
     }
 
     // MARK - Setters

public enum LatchAccessibility: RawRepresentable {
    /**
    Data can only be accessed while the device is unlocked. This is recommended
    for items that only need be accesible while the application is in the 
    foreground. 

    Data with this attribute will migrate to a new device when using encrypted
    backups.
    */
    case WhenUnlocked

    /**
    Data can only be accessed once the device has been unlocked after a restart.
    This is recommended for items that need to be accesible by background
    applications.

    Data with this attribute will migrate to a new device
    when using encrypted backups.
    */
    case AfterFirstUnlock

    /**
    Data can always be accessed regardless of the lock state of the device. 
    This is **not recommended** for anything except system use.

    Items with this attribute will migrate to a new device when using encrypted 
    backups.
    */
    case Always

    /**
    Data can only be accessed while the device is unlocked. This is recommended 
    for items that only need be accesible while the application is in the 
    foreground.

    Items with this attribute will never migrate to a new device, so after
    a backup is restored to a new device, these items will be missing.
    */
    case WhenUnlockedThisDeviceOnly

    /**
    Data can only be accessed once the device has been unlocked after a restart.
    This is recommended for items that need to be accessible by background
    applications.

    Items with this attribute will never migrate to a new device, so after a 
    backup is restored to a new device these items will be missing.
    */
    case AfterFirstUnlockThisDeviceOnly

    /**
    Data can always be accessed regardless of the lock state of the device. 
    This option is not recommended for anything except system use. 

    Items with this attribute will never migrate to a new device, so after a 
    backup is restored to a new device, these items will be missing.
    */
    case AlwaysThisDeviceOnly

    /**
    Create a new LatchAccessibility value using a kSecAttrAccessible value.

    Remove all objects from the keychain for the current app. Only available on
    iOS and watchOS.
    */
    @discardableResult public func resetKeychain() -> Bool {
        let query:[String: AnyObject] = [kSecClass as String : kSecClassGenericPassword]
        let status = SecItemDelete(query as CFDictionary)
        if status != errSecSuccess {
            print("Latch failed to reset keychain, error: \(status)")
            return false
