我该如何抑制/绕过代理警报

use*_*902 5 proxy-server ios nsurlsession swift

我在我的代码中使用代理并获得身份验证挑战.但在"didReceiveChallenge"被调用之前,我正在获得警报,如下图所示在此输入图像描述.如果我在警报上单击"取消",则调用"didReceiveChallenge".

let url = NSURL(string: "http://www.google.com")
let request = NSURLRequest(URL: url!)
let config = NSURLSessionConfiguration.ephemeralSessionConfiguration()

let proxyDict:[String:AnyObject] = [kCFNetworkProxiesHTTPEnable as String: true,
                                    hostKey as String:proxy_server,
                                    portKey as String: proxy_port,
                                    userNameKey as String:userName,
                                    passwordKey as String:password]

config.connectionProxyDictionary = proxyDict as [NSObject : AnyObject]

let session = NSURLSession(configuration: config, delegate: self, delegateQueue: NSOperationQueue.mainQueue())

let task = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in



    print(data)
    print(error)
    print(response)

});

task.resume()


  func URLSession(session: NSURLSession, didReceiveChallenge challenge:     NSURLAuthenticationChallenge, completionHandler:    (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) {
let credential = NSURLCredential(user:user, password:password, persistence: .ForSession)
      completionHandler(NSURLSessionAuthChallengeDisposition.UseCredential,credential)
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能抑制/绕过即将到来的警报?任何帮助是极大的赞赏.