据我所知,下面代码中的可选失败块已经被解包,?
但是 xCode 一直在抱怨我的语法。如果您仔细查看该success
块,它看起来与该failure
块完全一样,但不知何故,xCode 并没有标记该success
块。我以前遇到过这个问题,并设法通过构建清理解决了这个问题,但这次不是。有没有人遇到过类似的问题?
public func authorizeLogin(token: String, success: (() -> ())?, failure: (() -> ())?) {
let path = "me/two-step/push-authentication"
let requestUrl = self.pathForEndpoint(path, withVersion: ServiceRemoteRESTApiVersion_1_1)
let parameters = [
"action" : "authorize_login",
"push_token" : token
]
api.POST(requestUrl,
parameters: parameters,
success: { (operation: AFHTTPRequestOperation!, response: AnyObject!) -> Void in
success?()
},
failure:{ (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in
failure?()
})
}
这是带有错误消息的屏幕截图:
value of optional type '()?' not unwrapped; did you mean to use '!' or '?'