我知道这听起来很明显,但我收到了以下错误:No known class mehtod for selector 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没有看到这种方法?
答案 0 :(得分:1)
您的代码中缺少request
参数:
return [[[NSURLConnection rac_sendAsynchronousRequest:request]
map:^id(RACTuple *value) {
return [value second];
}]
deliverOn:[RACScheduler mainThreadScheduler]];