【问题标题】:Delegate method didReceiveAuthenticationChallenge is not getting called未调用委托方法 didReceiveAuthenticationChallenge
【发布时间】:2012-07-27 16:54:16
【问题描述】:
        - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {

            return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
        }

       - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {

        NSLog(@"got auth challange");
        NSURLCredential *newCredential;
        newCredential=[NSURLCredential credentialWithUser:    (NSString*)@"company//A1234"    
password:(NSString*)@"apple@999"
persistence:NSURLCredentialPersistencePermanent];
   [[challenge  sender] useCredential:newCredential     forAuthenticationChallenge:challenge];

        NSLog(@"Auth error: %@",[[challenge  error] description]);
        NSLog(@"Failure count:%d",[challenge previousFailureCount]); 
        }
        //- (id)initWithProxyHost:(NSString *)host port:(NSInteger)port type:(NSString *)type realm:(NSString *)realm  authenticationMethod:(NSString *)authenticationMethod{
        //    
        //    return self;
        //}

我使用这种方法从代理网络访问公共 url,但它的委托 didReceiveAuthenticationChallenge 没有被调用

【问题讨论】:

    标签: iphone ipad


    【解决方案1】:
     - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
    
            return YES;
        }
    

    然后它会调用!

    【讨论】:

      猜你喜欢
      • 2012-04-29
      • 1970-01-01
      • 2011-08-12
      • 1970-01-01
      • 2015-06-09
      • 2016-07-16
      相关资源
      最近更新 更多