I just upgraded to Xcode 8 and am already getting errors which cause the build to fail. I'm very new to swift, please help.
我刚刚升级到Xcode 8并且我已经收到错误导致构建失败。我很快乐,请帮忙。
What should I change this to? Thanks
我该怎么改成这个?谢谢
UPDATE
UPDATE
Apart from this error i also got the following:
除了这个错误,我还得到以下内容:
PFUser.logInWithUsername(inBackground: usernameTextField.text!, password: passwordTextField.text!, block: { (user, error) -> Void in
//self.activityIndicator.stopAnimating()
UIApplication.shared.endIgnoringInteractionEvents()
if user != nil {
self.launchDrawerMenu()
} else {
let convertedError = error! as NSError
//if let errorString = convertedError["error"] as? String {
errorMessage = errorString
}
self.displayAlert("Login failed", message: errorMessage)
}
})
for the // line I got "type NSError has no subscript members" error. I tried bridging it to NSError but it does not work this time. What should i do? thanks a lot
为//行我得到“类型NSError没有下标成员”错误。我尝试将它桥接到NSError,但这次它不起作用。我该怎么办?非常感谢
2 个解决方案
#1
24
First of all, post the code (text) rather than a screenshot.
首先,发布代码(文本)而不是截图。
In Swift 3 NSError
has been replaced in many API with more generic Swift Error
protocol which has no userInfo
dictionary. Bridge cast the object to NSError
在Swift 3中,NSError已被许多API替换为更通用的Swift Error协议,该协议没有userInfo字典。 Bridge将对象强制转换为NSError
if let errorString = (error! as NSError).userInfo....
#2
0
I found this worked
我觉得这很有效
let errorUserInfo : NSDictionary? = ((error as Any) as! NSError).userInfo["error"] as? NSDictionary
#1
24
First of all, post the code (text) rather than a screenshot.
首先,发布代码(文本)而不是截图。
In Swift 3 NSError
has been replaced in many API with more generic Swift Error
protocol which has no userInfo
dictionary. Bridge cast the object to NSError
在Swift 3中,NSError已被许多API替换为更通用的Swift Error协议,该协议没有userInfo字典。 Bridge将对象强制转换为NSError
if let errorString = (error! as NSError).userInfo....
#2
0
I found this worked
我觉得这很有效
let errorUserInfo : NSDictionary? = ((error as Any) as! NSError).userInfo["error"] as? NSDictionary