How to call SecItemCopyMatching in Xcode 7 beta 4?

后端 未结 2 1445
终归单人心
终归单人心 2021-02-09 09:14

In previous versions of Xcode 6 and 7 with Swift, this syntax would work:

    var secureItemValue: Unmanaged?

    let statusCode: OSStatus = Se         


        
2条回答
  •  故里飘歌
    2021-02-09 10:04

    This works on Xcode 7 beta 4

    var dataTypeRef: AnyObject?
    
        let status: OSStatus = withUnsafeMutablePointer(&dataTypeRef) { SecItemCopyMatching(keychainQuery as CFDictionaryRef, UnsafeMutablePointer($0)) }
    
        if status == noErr {
            return dataTypeRef as? NSData
        }
        else {
            return nil
        }
    

提交回复
热议问题