Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift - Converting an AutoreleasingUnsafeMutablePointer<AnyObject?> value

So far I have this code:

var thumbnailErr: NSError?
var thumbnailDictionary: AutoreleasingUnsafeMutablePointer<AnyObject?> = nil
let getItemSucceeded = url.getPromisedItemResourceValue(thumbnailDictionary, forKey: NSURLThumbnailDictionaryKey, error: &thumbnailErr)
if getItemSucceeded {

}

Now I want to turn thumbnailDictionary into a Dictionary or NSDictionary. This is how I do it in Objective-C:

BOOL thumbnailSucceeded = [urlFromPath getPromisedItemResourceValue:thumbnailDictionary forKey:NSURLThumbnailDictionaryKey error:&thumbnailErr];
if (thumbnailSucceeded) {
    NSDictionary *dict = (__bridge NSDictionary *)(void *)thumbnailDictionary;
}

I cannot for the life of me figure out how to do this in Swift. Help?

like image 518
arcticmatt Avatar asked Aug 28 '14 00:08

arcticmatt


1 Answers

Got it. Passing in an AutoreleasingUnsafeMutablePointer wasn't necessary.

var thumbnailErr: NSError?
var thumbnailDictionary: AnyObject?
let getItemSucceeded = url.getPromisedItemResourceValue(&thumbnailDictionary, forKey: NSURLThumbnailDictionaryKey, error: &thumbnailErr)
if getItemSucceeded {
    let dict = thumbnailDictionary as NSDictionary
}
like image 73
arcticmatt Avatar answered Sep 19 '22 15:09

arcticmatt