美文网首页
iOS ---------NSURLSession/NSURLC

iOS ---------NSURLSession/NSURLC

作者: 飘渺阿天 | 来源:发表于2017-05-15 16:45 被阅读32次

    遇到此问题的解决办法:

    使用中的didReceiveChallenge方法,方法中的代码如下:

    - (void)URLSession:(NSURLSession *)sessiondidReceiveChallenge:(NSURLAuthenticationChallenge *)challenge

    completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition,NSURLCredential * __nullable credential))completionHandler

    {

    NSLog(@"didReceiveChallenge");

    completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredentialcredentialForTrust:challenge.protectionSpace.serverTrust]);

    }

    当然,info.plist里面也要加上下面这段:

    NSAppTransportSecurity

    NSAllowsArbitraryLoads

    相关文章

      网友评论

          本文标题:iOS ---------NSURLSession/NSURLC

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