gpt4 book ai didi

ios - 选择器 rac 发送异步请求没有已知的类方法

转载 作者:行者123 更新时间:2023-11-29 12:05:07 25 4
gpt4 key购买 nike

我知道这听起来很明显,但我收到以下错误: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 看不到该方法?

最佳答案

您的代码中缺少 request 参数:

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

return [value second];
}]

deliverOn:[RACScheduler mainThreadScheduler]];

关于ios - 选择器 rac 发送异步请求没有已知的类方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35334765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com