0
我有這個奇怪的錯誤,並沒有任何想法熱點解決它。錯誤swift 3從「PHAsset?」下載到'PHAsset'只解開可選項;你的意思是使用'!'嗎?
我的代碼在Xcode 7.3中運行良好。但是,在更新到Xcode 8之後,我得到了近17個錯誤和21個警告。這可能是Swift 3中的一些語法變更。
解決了所有這些問題,但無法弄清楚這一點:Downcast from'PHAsset?'到'PHAsset'只解開可選項;你的意思是使用'!'嗎?
幫助,請
let valorFoto = tuplesFoto.valorfoto.substring(to: tuplesFoto.valorfoto.characters.index(tuplesFoto.valorfoto.endIndex, offsetBy: -4))
if let asset = PHAsset.fetchAssets(withLocalIdentifiers: [valorFoto], options: nil).firstObject as? PHAsset
{
PHImageManager.default().requestImageData(for: asset, options: nil, resultHandler: { (data: Data?, identificador: String?, orientaciomImage: UIImageOrientation, info: [AnyHashable: Any]?) -> Void in
if let data = data
{
if let image = UIImage(data: data)
{
DispatchQueue.main.async(execute: {() -> Void in
self.images.updateValue(image, forKey: tuplesFoto.valorfoto)
self.colDragAndDrop.reloadData()
})
}
}
})
}
else
{
if let image = UIImage(named: "no_media")
{
images.updateValue(image, forKey: tuplesFoto.valorfoto)
}
}
聽起來像是'fetchAssets'返回''PHAsset?你有沒有嘗試只是刪除'as? PHAsset'? – zneak
它的工作。我送達你的答案非常感謝你 – david