I'm building an iOS app that makes GET
requests to a URL. For all the requests it makes, I build the url off a base URL and than add parameters using NSDictionary
Key-Value_pairs.
I also use AFNetworking 2.0
to make the request - it builds the URL as well, with the NSDictionary keys supplied.
I have now run into a problem, where a web service I need to use, requires multiple keys to be the same, with different values. This functionality is not possible with NSDictionary
Which means I cannot run the web service successfully.
Here is an example of what I need the finally URL to look like -
http://demo.domain.net/services/.....&IncludedUserIds=12345&IncludedUserIds=2345
The italic bit of the above URL is what I am trying to build using AFNetworking and NSDictionary. I suspect I will have to use something a little more advanced than NSDictionary to pull this off.
Does anyone have any ideas?
Edit
Found a half solutions if I set my NSDictionary Parameters like this with NSSet:
[self.parameters setObject:[NSSet setWithObjects:@"12345",@"2345", nil] forKey:@"IncludedUserIds"];
This works as I need it to. However I have a follow up question:
The values need to be dynamically added to NSSet - how do I create an NSSet that can accept extra values at runtime?
I managed to solve this issue:
I just created objects in my NSDictionaray like so:
[self.myDictionary setObject:[NSSet setWithArray:self.myArray] forKey:@"myKeyNeeded];
The array has NSString objects in it and this seems to work perfectly.
I used array instead of NSMutableSet
due needing to remove objects easily enough from the NSDictionary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With