How can I create a single key url multiple times?

I am creating an iOS application that makes requests GETto a url. For all the requests he makes, I build the URL from the base URL and add parameters using NSDictionaryKey-Value_pairs.

I also use AFNetworking 2.0to make a request - it also creates a URL, with NSDictionary keys provided.

Now I have a problem when I want to use a web service, which requires that several keys are the same, with different values. This function is not possible whenNSDictionary

This means that I cannot successfully start the web service.

Here is an example of what I need for the url to finally look -

http://demo.domain.net/services/ ..... & IncludedUserIds = 12345 & IncludedUserIds = 2345

The bright bit of the above URL is what I'm trying to build using AFNetworking and NSDictionary. I suspect that I will have to use something more advanced than NSDictionary to remove this.

Does anyone have any ideas?

Edit

Half solutions were found if I set NSDictionary parameters like NSSet:

    [self.parameters setObject:[NSSet setWithObjects:@"12345",@"2345", nil] forKey:@"IncludedUserIds"];

It works the way I need. However, I have the following question:

Values ​​must be dynamically added to the NSSet - how do I create an NSSet that can take extra values ​​at runtime?

+4
source share
2 answers

I managed to solve this problem:

NSDictionaray :

    [self.myDictionary setObject:[NSSet setWithArray:self.myArray] forKey:@"myKeyNeeded];

NSString, , , . NSMutableSet - NSDictionary.

+4

, , &IncludedUserIds=12345&IncludedUserIds=2345 , &IncludedUserIds=12345,2345

, - .

0

Source: https://habr.com/ru/post/1536439/


All Articles