美文网首页
Swift 3之Alamofire配置Timeout

Swift 3之Alamofire配置Timeout

作者: VincentZhou | 来源:发表于2017-03-20 10:22 被阅读1780次

    let manager = Alamofire.SessionManager.default
    manager.session.configuration.timeoutIntervalForRequest = 120

    manager.request("yourUrl", method: .post, parameters: ["parameterKey": "value"])
    .responseJSON {
    response in
    switch (response.result) {
    case .success:
    //do json stuff
    break
    case .failure(let error):
    if error._code == NSURLErrorTimedOut {
    //timeout here
    }
    print("\n\nAuth request failed with error:\n (error)")
    break
    }
    }

    相关文章

      网友评论

          本文标题:Swift 3之Alamofire配置Timeout

          本文链接:https://www.haomeiwen.com/subject/xjebnttx.html