2013-06-30 24 views
1

我試圖重寫-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經驗,所以也許我做了一些愚蠢的事情,但我找不到編譯錯誤的原因。

回答

0

好吧,我發現了這個問題。我曾在文件中定義

#define _AFNETWORKING_PIN_SSL_CERTIFICATES_ 

,我試着打setWillSendRequestForAuthenticationChallengeBlock:

我明白的CocoaPods已經做了豆莢,prefix.pch的#define和沒想到的是,應該重新定義。