I faced a similar problem where I had multiple parameters and one of them (only one of the parameters) was supposed to be an array. The easier way I found was to add the values for that array to an NSMutableArray and then transfer those values to the parameter:
//Don't forget to set this array to retain its values in the property
self.arrSelected = [[NSMutableArray alloc]initWithArray:nil];
if(switch1.selected){
[self.arrServicesSelected addObject:@"value1"];
}
if(switch2.selected){
[self.arrServicesSelected addObject:@"value2"];
}
if(switch3.selected){
[self.arrServicesSelected addObject:@"value3"];
}
Then you just need to go through the array and add the values to the POST parameter. Make sure you add them to different indices. I have seen some people adding to the [] without the index and that will not work as it will add only the last one. If you don't use the [] you will only add the first one.
for(int i=0; i< [self.arrSelected count];i++){
[requestPOST setPostValue:[self.arrSelected objectAtIndex:i] forKey:[NSString stringWithFormat:@"chk_parameter_serv[%i]", i]];
}
You can also use the forin syntax:
int i=0;
for(NSString *strValue in self.arrSelected)
[requestPOST setPostValue:strValue forKey:[NSString stringWithFormat:@"chk_parameter_serv[%i]", i++]];