iOS4 - problem urlencoding a string
I'm having a problem when trying to urlencode a string containing an ampersand. I'm using the following code:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *sta开发者_开发问答dium = [[prefs stringForKey:@"stadiumname"]
stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
Now, the original string going in is "Brighton & Hove", which is correct when I drop it into NSLog before it gets encoded. After it's encoded, NSLog shows that it says "Brighton22ove", which is obviously failing when I pass it as a querystring.
Any suggestions?
I've actually found the answer now at: cybersam.com/programming/proper-url-percent-encoding-in-ios All the code and examples are on that page
精彩评论