I am making request on server , having spaces in URL
http://xxxxxxxx.com/api/api.php?func=showAllwedsdwewsdsd¶ms[]=Saudi%20Arab¶ms[]=all
I was getting the error Bad URL so ,
I used
downloadURL = [downloadURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
but due this I am getting strange URL as
http://sdsdsdsdsdsd.com/api/api.php?func=showAllsdsd¶ms5262721536=Saudi 0X0P+0rabia¶ms5 8288=All
I am also using
downloadURL= [downloadURL stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
but again strange url like
http://xxxxxxxxx.com/api/api.php?func=showsdsdsd¶ms[]=Saudi 0X1.240DC0D824P-807rabia¶ms[]=All
Please help how can I solve this issue
Edit Pasting Big portion of code
PropertyXMLDownloader *download=[[PropertyXMLDownloader alloc]init];
[download setDelegate:self];
firstAppDelegate *del=(firstAppDelegate *)[[UIApplication sharedApplication]delegate];
NSLog(@"Country is %@",del.country);
NSLog(@"State is %@",del.state);
// del.country=[del.country stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSString *downloadURL=[NSString stringWithFormat:@"http://xxxxxxxx.com/api/api.php?func=showAll¶ms[]=Saudi Arabia¶ms[]=%@",@"all"];
// downloadURL= [downloadURL stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
//downloadURL = [downloadURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@" "];
downloadURL = [[downloadURL componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString:@"%20"];
NSLog(downloadURL);
[download startDownloading:downloadURL];
try this.
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@" "];
downloadURL = [[downloadURL componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString:@"%20"];