error.userInfonot optional, this is the type the [NSObject : AnyObject]compiler hinted at. There is no need to deploy it with the help if let, it will never be nil.
You can replace
if let info = error.userInfo {
ProgressHUD.showError(info["error"] as! String)
}
from
ProgressHUD.showError(error.userInfo["error"] as! String)
if you are sure that the value will be String.
Otherwise, the dictionary value must be safely expanded and omitted as a string. Example:
if let errorString = error.userInfo["error"] as? String {
ProgressHUD.showError(errorString)
}
source
share