ViewController的两个区域都显示此警告。
geoCoder.reverseGeocodeLocation(location, completionHandler: { (data, error) -> Void in
guard let placeMarks = data as? [CLPlacemark] else { // warning
return
}
let loc: CLPlacemark = placeMarks[0]
let addressDict : [NSString: NSObject] = loc.addressDictionary as! [NSString: NSObject]
let addrList = addressDict["FormattedAddressLines"] as! [String]
〜和〜
func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
print("Returning Custom label")
var label = view as! UILabel!// warning
if label == nil {
label = UILabel()
}
label?.font = UIFont(name: "Avenir", size: 18)!
....
如何解决这些问题?
答案 0 :(得分:0)
根据SE-0054提案(自Swift 4.2起已实施),隐式未包装的可选值的使用仅限于:
以as!
向下广播不是其中之一