到目前为止,我有这段代码:
var thumbnailErr: NSError?
var thumbnailDictionary: AutoreleasingUnsafeMutablePointer<AnyObject?> = nil
let getItemSucceeded = url.getPromisedItemResourceValue(thumbnailDictionary, forKey: NSURLThumbnailDictionaryKey, error: &thumbnailErr)
if getItemSucceeded {
}
现在我想将thumbnailDictionary转换为Dictionary或NSDictionary。这就是我在Objective-C中的表现:
BOOL thumbnailSucceeded = [urlFromPath getPromisedItemResourceValue:thumbnailDictionary forKey:NSURLThumbnailDictionaryKey error:&thumbnailErr];
if (thumbnailSucceeded) {
NSDictionary *dict = (__bridge NSDictionary *)(void *)thumbnailDictionary;
}
我不能为我的生活弄清楚如何在Swift中做到这一点。帮助
答案 0 :(得分:21)
知道了。无需传入AutoreleasingUnsafeMutablePointer。
var thumbnailErr: NSError?
var thumbnailDictionary: AnyObject?
let getItemSucceeded = url.getPromisedItemResourceValue(&thumbnailDictionary, forKey: NSURLThumbnailDictionaryKey, error: &thumbnailErr)
if getItemSucceeded {
let dict = thumbnailDictionary as NSDictionary
}