简体   繁体   中英

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. My question to you guys there is way to replace setParameters to add the parameters to the NSURLRequest?

I'll really appreciate your help

It looks like you're trying to add URL parameters to an 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. There's definitely no way to set URL parameters on an NSURLRequest. You can see them with myReq.URL.parameterString but definitely can't set them.

如果希望在初始化后能够修改NSURLRequest ,则应改用NSMutableURLRequest

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM