Fixed trying to decode the response object for non-read requests

This commit is contained in:
matthewpalmer
2014-11-14 13:11:41 +11:00
parent 802f5405dc
commit da755c7575
3 changed files with 49 additions and 4 deletions
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>6AAF752A-6001-46C3-BB3E-4EA76720DE90</string>
<key>IDESourceControlProjectName</key>
<string>Locksmith</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>9E5DC2F442C5D1D821707804A23B5D894E49AF44</key>
<string>https://github.com/matthewpalmer/Locksmith</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Locksmith.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>9E5DC2F442C5D1D821707804A23B5D894E49AF44</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/matthewpalmer/Locksmith</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>9E5DC2F442C5D1D821707804A23B5D894E49AF44</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>9E5DC2F442C5D1D821707804A23B5D894E49AF44</string>
<key>IDESourceControlWCCName</key>
<string>Locksmith</string>
</dict>
</array>
</dict>
</plist>
+8 -4
View File
@@ -23,7 +23,7 @@ class Locksmith: NSObject {
switch type {
case .Create:
status = SecItemAdd(requestReference, nil)
status = SecItemAdd(requestReference, &result)
case .Read:
status = SecItemCopyMatching(requestReference, &result)
case .Delete:
@@ -37,9 +37,13 @@ class Locksmith: NSObject {
let error = Locksmith.keychainError(forCode: statusCode)
var resultsDictionary: NSDictionary?
if let data: NSData = result?.takeRetainedValue() as? NSData {
// Convert the retrieved data to a dictionary
resultsDictionary = NSKeyedUnarchiver.unarchiveObjectWithData(data) as? NSDictionary
if let rawValue = result {
if type == .Read {
if let data = rawValue.takeRetainedValue() as? NSData {
// Convert the retrieved data to a dictionary
resultsDictionary = NSKeyedUnarchiver.unarchiveObjectWithData(data) as? NSDictionary
}
}
}
return (resultsDictionary, error)