Evgeniy Kleban
Evgeniy Kleban

Reputation: 6940

No known class mehtod for selector rac_sendAsynchronousRequest

I know that may sound obvious, but i got following error: No known class mehtod for selector rac_sendAsynchronousRequest

in a line:

return [[[NSURLConnection rac_sendAsynchronousRequest]

Whole method body is :

+(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]];

}

In my header i did import both category and library headers:

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

In NSURLConnection+RACSupport.h i can see method declaration:

@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

Why does XCode doesn't see that method?

Upvotes: 1

Views: 86

Answers (1)

Michał Ciuba
Michał Ciuba

Reputation: 7944

The request parameter is missing in your code:

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

                  return [value second];
              }]

            deliverOn:[RACScheduler mainThreadScheduler]];

Upvotes: 1

Related Questions