サーバー上でリクエストを作成していますが、URL にスペースが含まれています
http://xxxxxxxx.com/api/api.php?func=showAllwedsdwewsdsd¶ms[]=サウジアラビア%20アラブ¶ms[]=all
Bad URL というエラーが表示されたので、
使った
downloadURL = [downloadURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
しかし、これにより、奇妙なURLを取得しています
http://sdsdsdsdsdsd.com/api/api.php?func=showAllsdsd¶ms5262721536=Saudi 0X0P+0rabia¶ms5 8288=All
私も使っています
downloadURL= [downloadURL stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
しかし、再び奇妙なURLのような
http://xxxxxxxxx.com/api/api.php?func=showsdsdsd¶ms[]=Saudi 0X1.240DC0D824P-807rabia¶ms[]=All
この問題を解決するにはどうすればよいですか
コードの大部分の貼り付けを編集
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];