我試圖重寫-HTTPRequestOperationWithRequest:成功:失敗:如下面的代碼中AFHTTPClient方法:無法調用setWillSendRequestForAuthenticationChallengeBlock:上AFHTTPRequestOperation
-(AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure {
AFHTTPRequestOperation *requestOperation = [super HTTPRequestOperationWithRequest:urlRequest success:success failure:failure];
[requestOperation setWillSendRequestForAuthenticationChallengeBlock:^(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge) {
}];
return requestOperation;
}
當我嘗試編譯它,雖然我得到以下錯誤:
No visible @interface for 'AFHTTPRequestOperation' declares the selector 'setWillSendRequestForAuthenticationChallengeBlock:'
的setWillSendRequestForAuthenticationChallengeBlock:方法在AFURLConnectionOperation定義,但AFHTTPRequestOperation是一個子類,因此,該方法應在AFHTTPRequestOperatio可用n也是如此。
我沒有太多的Objective-C經驗,所以也許我做了一些愚蠢的事情,但我找不到編譯錯誤的原因。