             returnDict[key] = value
         }
         
-        returnDict[kSecClass] = kSecClassGenericPassword
+        returnDict[kSecClass as String] = kSecClassGenericPassword
         
-        returnDict[kSecValueData] = NSJSONSerialization.dataWithJSONObject(self.values, options: .allZeros, error: nil)
+        do {
+            try returnDict[kSecValueData as String] = NSJSONSerialization.dataWithJSONObject(self.values, options: NSJSONWritingOptions())
+        } catch _ {
+            
+        }
         
         return returnDict
     }
     
     private func writeKeychainData() {
-        var attributes: Unmanaged<AnyObject>?
+        var attributes: AnyObject?
         var updateItem: [String: AnyObject]?
         
         var result: OSStatus?

            returnDict[key] = value
        }
        
        returnDict[kSecReturnData] = kCFBooleanTrue
        returnDict[kSecClass] = kSecClassGenericPassword
        
        var passwordData: Unmanaged<AnyObject>?
        
        // We could use returnDict like the Apple example but this crashes the app with swift_unknownRelease
        // when we try to access returnDict again
        var queryDict = returnDict
        
        let copyMatchingResult = SecItemCopyMatching(queryDict as CFDictionary, &passwordData)
        
        if copyMatchingResult != noErr {
            assert(false, "No matching item found in keychain")
        } else {
            let retainedValuesData = passwordData!.takeRetainedValue() as NSData
            var val = NSJSONSerialization.JSONObjectWithData(retainedValuesData, options: .allZeros, error: nil) as [String: AnyObject]
            
            returnDict.removeValueForKey(kSecReturnData)
            returnDict[kSecValueData] = val
            
            self.values = val
        }
        
        return returnDict

        }
    }
    
    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 as String] = ""
        self.keychainItemData[kSecAttrLabel as String] = ""
        self.keychainItemData[kSecAttrDescription as String] = ""
        
        self.keychainItemData[kSecValueData as String] = ""
    }
    
    private func secItemDataToDict(data: [String: AnyObject]) -> [String: AnyObject] {
