在swift中返回嵌套闭包

时间:2015-08-12 18:36:16

标签: ios swift

嗨有没有办法可以退出嵌套的闭包,这里是代码

context.Users

当我想要返回端点时,我得到这个“LokaliiAuthorizationAPI无法转换为()”错误

let authorizationEndpointsClosure = { (target: LokaliiAuthorizationAPI) -> Endpoint<LokaliiAuthorizationAPI> in
    let url = target.baseURL.URLByAppendingPathComponent(target.path).absoluteString
    let endpoint = Endpoint<LokaliiAuthorizationAPI>(URL: url!, sampleResponse: .Success(200, {target.sampleData}), method: target.method, parameters: target.parameters)

switch target {
case .TokenRequest,
    return endpoint
default:
    MNAuthClient.sharedClient.retriveAccessToken() { result in
        switch result {
        case .Success(let succ):
            let token = succ.value
            return endpoint.endpointByAddingHTTPHeaderFields(["Authorization": "Bearer \(token.accessToken)"])
        case .Failure(let error):
            return endpoint
            println("Error for refresh token : \(error.value)")
        }
    }

}
}

0 个答案:

没有答案