Browse Source

Fix crash in ad hoc mode

Evgenii Neumerzhitckii 10 years ago
parent
commit
9b36285002

BIN
keychain.xcodeproj/project.xcworkspace/xcuserdata/evgenyneu.xcuserdatad/UserInterfaceState.xcuserstate


+ 4 - 2
keychain.xcodeproj/xcuserdata/evgenyneu.xcuserdatad/xcschemes/keychain.xcscheme

@@ -72,7 +72,8 @@
       ignoresPersistentStateOnLaunch = "NO"
       debugDocumentVersioning = "YES"
       allowLocationSimulation = "YES">
-      <BuildableProductRunnable>
+      <BuildableProductRunnable
+         runnableDebuggingMode = "0">
          <BuildableReference
             BuildableIdentifier = "primary"
             BlueprintIdentifier = "2BCB008B1A83354D0022C93A"
@@ -90,7 +91,8 @@
       useCustomWorkingDirectory = "NO"
       buildConfiguration = "Release"
       debugDocumentVersioning = "YES">
-      <BuildableProductRunnable>
+      <BuildableProductRunnable
+         runnableDebuggingMode = "0">
          <BuildableReference
             BuildableIdentifier = "primary"
             BlueprintIdentifier = "2BCB008B1A83354D0022C93A"

+ 5 - 5
keychain/TegKeychain.swift

@@ -51,14 +51,14 @@ public class TegKeychain {
       TegKeychainConstants.returnData  : kCFBooleanTrue,
       TegKeychainConstants.matchLimit  : kSecMatchLimitOne ]
     
-    var dataTypeRef :Unmanaged<AnyObject>?
+    var result: AnyObject?
     
-    let status: OSStatus = SecItemCopyMatching(query, &dataTypeRef)
+    let status = withUnsafeMutablePointer(&result) {
+      SecItemCopyMatching(query, UnsafeMutablePointer($0))
+    }
     
     if status == noErr {
-      if let currentDataTypeRef = dataTypeRef {
-        return currentDataTypeRef.takeRetainedValue() as? NSData
-      }
+      return result as? NSData
     }
     
     return nil