2016-02-11 46 views
1

我知道這聽起來很明顯,但我得到了以下錯誤:在一條線上No known class mehtod for selector rac_sendAsynchronousRequest的選擇沒有已知的類mehtod rac_sendAsynchronousRequest

return [[[NSURLConnection rac_sendAsynchronousRequest] 

整個方法體是:

+(RACSignal*)download:(NSString*)urlString{ 

    NSAssert(urlString, @"URL must not be nil"); 

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]; 

    return [[[NSURLConnection rac_sendAsynchronousRequest] 
       map:^id(RACTuple *value) { 

        return [value second]; 
       }] 

      deliverOn:[RACScheduler mainThreadScheduler]]; 

} 

在我的標題中,我確實導入了類別和庫標題:

#import<ReactiveCocoa/ReactiveCocoa.h> 
#import <ReactiveCocoa/NSURLConnection+RACSupport.h> 

NSURLConnection+RACSupport.h我可以看到方法聲明:

@class RACSignal; 

@interface NSURLConnection (RACSupport) 

// Lazily loads data for the given request in the background. 
// 
// request - The URL request to load. This must not be nil. 
// 
// Returns a signal which will begin loading the request upon each subscription, 
// then send a `RACTuple` of the received `NSURLResponse` and downloaded 
// `NSData`, and complete on a background thread. If any errors occur, the 
// returned signal will error out. 
+ (RACSignal *)rac_sendAsynchronousRequest:(NSURLRequest *)request; 

@end 

爲什麼的XCode沒有看到的方法?

回答

1

request參數丟失,在你的代碼:

return [[[NSURLConnection rac_sendAsynchronousRequest:request] 
       map:^id(RACTuple *value) { 

        return [value second]; 
       }] 

      deliverOn:[RACScheduler mainThreadScheduler]]; 
+0

ciuba謝謝! –

相關問題