AFHTTPRequestOperation setAuthenticationAgainstProtectionSpaceBlock无法识别的选择器错误:

use*_*487 0 objective-c afnetworking

我正在尝试在IOS中运行以下代码.

AFHTTPRequestOperation *requestOperation = [self.httpClient HTTPRequestOperationWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url.text]]
                                         success:^(AFHTTPRequestOperation *operation, id responseObject) {
                                           NSLog(@"reply data = %@", [[NSString alloc] initWithData:operation.responseData encoding:NSUTF8StringEncoding]);
                                         }
                                         failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                                           NSLog(@"%@", error);
                                         }];
[requestOperation setAuthenticationAgainstProtectionSpaceBlock:^BOOL(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace) {
  return YES;
}];
Run Code Online (Sandbox Code Playgroud)

然后我得到这样的错误:

- [AFHTTPRequestOperation setAuthenticationAgainstProtectionSpaceBlock:]:无法识别的选择器发送到实例0x75a81f0

据我所知,我传递的块具有正确的返回类型和参数.我在这做错了什么?

mat*_*ttt 5

AFURLRequestOperation有条件地使用某些可用的委托回调方法进行编译,具体取决于是否_AFNETWORKING_PIN_SSL_CERTIFICATES_已定义.

如果是(从CocoaPods安装时是默认设置),setWillSendRequestForAuthenticationChallengeBlock:将可用.否则,setAuthenticationAgainstProtectionSpaceBlock:setAuthenticationChallengeBlock:将可用.

setWillSendRequestForAuthenticationChallengeBlock对应于connection:willSendRequest:forAuthenticationChallenge:,这是处理挑战的首选委托方法.