[英]iOS: instance method -setParameters not found
I'm updating old implementation. 我正在更新旧的实现。 But I'm getting this error:
但我收到此错误:
instance method -setParameters not found
on this line: 在这条线上:
[request setParameters:self.parameters];
But I found this: 但是我发现了这一点:
@property (nonatomic, copy) NSDictionary *parameters NS_AVAILABLE_IOS(9_0);
This is how parameters is been set: 这是设置参数的方式:
- (id)initWithURL:(NSURL *)aURL parameters:(NSArray *)theParameters files:(NSDictionary*)theFiles {
return [self initWithURL:aURL
method:@"POST"
parameters:theParameters
files:theFiles];
}
or 要么
- (id)initWithURL:(NSURL *)aURL parameters:(NSArray *)theParameters {
return [self initWithURL:aURL
method:nil
parameters:theParameters];
}
Basically is adding some parameters to NSURLRequest. 基本上是向NSURLRequest添加一些参数。 My question to you guys there is way to replace setParameters to add the parameters to the NSURLRequest?
我想问的问题是,有一种方法可以替换setParameters,以将参数添加到NSURLRequest吗?
I'll really appreciate your help 非常感谢您的帮助
It looks like you're trying to add URL parameters to an NSURLRequest. 似乎您正在尝试将URL参数添加到NSURLRequest。 There is a property on NSURL for parameterString but it is readonly, which is why you're only able to set it using the initializer.
NSURL上有一个用于parameterString的属性,但它是只读的,这就是为什么您只能使用初始化程序进行设置的原因。 There's definitely no way to set URL parameters on an NSURLRequest.
绝对没有办法在NSURLRequest上设置URL参数。 You can see them with
myReq.URL.parameterString
but definitely can't set them. 您可以使用
myReq.URL.parameterString
看到它们,但绝对不能设置它们。
如果希望在初始化后能够修改NSURLRequest
,则应改用NSMutableURLRequest
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.