I am trying to parse data from a xml web service but I am not able to get my url. Please check my code:
NSLog(@"log url: %@",url);
[url stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];
NSLog(@"%@",url);
[url stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSLog(@"%@",url);
NSURL *URL = [NSURL URLWithString:url];
NSXMLParser *home_Parser = [[NSXMLParser alloc] initWithContentsOfURL:URL];
[home_Parser setDelegate:self];
[home_Parser parse];
[home_Parser release];
I am always getting URL as nil. The reason is my string url has space included. I have tried to replace it and escape it but it is not working. Following is the url that I am using
http://www.mydomain.com/radioListGenre.php?genre=Radiostations playing Rock
how can I remove this space. Is there any other technique the those I used above.
Thanks
Pankaj
stringByAddingPercentEscapesUsingEncodingandstringByReplacingOccurrencesOfStringoperate on the string provided and return a string. You’re not assigning the return value to anything so url isn’t changing, the return value is just vanishing into space. You want something more like:assuming url is a mutable string. Now url contains the modified version of url. Without the assignment it’s effective the same as doing something like this:
instead of: