I'm attempting to call SecItemCopyMatching in my keychain utility class in order to get data out of the keychain, yet I'm running into a problem with getting the result argument, UnsafeMutablePointer<CFTypeRef?>.
The original statement (in Swift 2, before migrating to Swift 3) was
// query is a dictionary of [String : AnyObject]
var result: Data?
let status = withUnsafeMutablePointer(to: &result) {
    SecItemCopyMatching(query as CFDictionary, UnsafeMutablePointer($0))
}
But in Swift 3, you are now required to call .withMemoryRebound in order to view memory. Based on what Xcode tells you to do, I tried this
var result: Data?
let status = withUnsafeMutablePointer(to: &result){
    $0.withMemoryRebound(to: Data.self, capacity: 1){
        SecItemCopyMatching(query as CFDictionary, UnsafePointer($0))
    }
}
Yet doing this, I get an error
Cannot convert value of type '
UnsafePointer<_>' to expected argument type 'UnsafeMutablePointer<CFTypeRef?>?'
So, I tried using CFTypeRef instead of Data
var result: CFTypeRef?
let status = withUnsafeMutablePointer(to: &result){
    $0.withMemoryRebound(to: CFTypeRef.self, capacity: 1){
        SecItemCopyMatching(query as CFDictionary, UnsafePointer($0))
    }
}
Replacing UnsafePointer($0) with simply $0 results in the same error message.
How can I get an UnsafeMutablePointer<CFTypeRef?> for getting data from keychain?
 
    