         }
     }
     
+    func objectForKey(key: String) -> AnyObject? {
+        return self.values[key]
+    }
+    
+    func setObject(newValue: AnyObject?, forKey key: String) {
+        self.values[key] = newValue
+        self.writeKeychainData()
+    }
+    
+    func resetKeychainItem() {
+        self.resetKeychain()
+    }
+    
     func resetKeychain() {
         
         if !self.keychainItemData.isEmpty {
             let tempDict = self.dictToSecItemData(self.keychainItemData)
             var junk = noErr
             junk = SecItemDelete(tempDict as CFDictionary)
-        
+            
             assert(junk == noErr || junk == errSecItemNotFound, "Failed to delete current dict")
         }
         
-        self.keychainItemData[kSecAttrAccount] = ""
-        self.keychainItemData[kSecAttrLabel] = ""
-        self.keychainItemData[kSecAttrDescription] = ""
+        self.keychainItemData[kSecAttrAccount as String] = ""
+        self.keychainItemData[kSecAttrLabel as String] = ""
+        self.keychainItemData[kSecAttrDescription as String] = ""
         
-        self.keychainItemData[kSecValueData] = ""
+        self.keychainItemData[kSecValueData as String] = ""
     }
     
     private func secItemDataToDict(data: [String: AnyObject]) -> [String: AnyObject] {

            assert(result == noErr, "Failed to add keychain item")
        } else {
            updateItem = [String: AnyObject]()
            for (key, value) in attributes!.takeRetainedValue() as [String: AnyObject] {
                updateItem![key] = value
            }
            updateItem![kSecClass] = self.genericPasswordQuery[kSecClass]
            
            var tempCheck = self.dictToSecItemData(self.keychainItemData)
            tempCheck.removeValueForKey(kSecClass)
            
            if TARGET_IPHONE_SIMULATOR == 1 {
                tempCheck.removeValueForKey(kSecAttrAccessGroup)
            }
            
            result = SecItemUpdate(updateItem! as CFDictionary, tempCheck as CFDictionary)
            assert(result == noErr, "Failed to update keychain item")
        }
    }
}
            returnDict[key] = value
        }
        
        returnDict[kSecReturnData as String] = kCFBooleanTrue
        returnDict[kSecClass as String] = kSecClassGenericPassword
        
        var passwordData: AnyObject?
        
        // We could use returnDict like the Apple example but this crashes the app with swift_unknownRelease
        // when we try to access returnDict again
        let queryDict = returnDict
        
        let copyMatchingResult = SecItemCopyMatching(queryDict as CFDictionary, &passwordData)
        
        if copyMatchingResult != noErr {
            assert(false, "No matching item found in keychain")
        } else {
            let retainedValuesData = passwordData as! NSData
            do {
                let val = try NSJSONSerialization.JSONObjectWithData(retainedValuesData, options: NSJSONReadingOptions()) as! [String: AnyObject]
                
                returnDict.removeValueForKey(kSecReturnData as String)
                returnDict[kSecValueData as String] = val
                
                self.values = val
            } catch _ {
                
            }
        }
        
        return returnDict
