I am trying to create a string with parameters that I pass to a web service, but I never know how many parameters there are going to be until runtime.
All of the parameters are stored in an array, and I iterate through the array, adding each one the the string.
The variables on the .php side are labeled field1, field2, field3, etc.
My problem lies when I try to declare the string in the for loop. I am trying to use x and append that to the word "field" so that I can end up with field1, field2, filed3, etc.
When I try to do this, there is an error message saying that there were more parameters than expected.
Here's what I have:
NSString *URLWithParameters = [NSString stringWithFormat:@"http://www.mywebsite/service?"];
for (int x = 0; x < [fields count]; x++) {
NSString *temp = [NSString stringWithString:@"field%i=%@&", x, (NSString *)[fields objectAtIndex:x]];
URLWithParameters = [URLWithParameters stringByAppendingString:temp];
}