Google it.
You’ll find there are a ton of solutions, all of them produce memory related errors because of ARC.
if you want to do it in a way that works, just:
NSString *charactersToEscape = @"!*'();:@&=+$,/?%#[]" "; NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:charactersToEscape] invertedSet]; NSString *url = [NSString stringWithFormat:@"%@", @"http://stuff.com/things/"]; NSString *encodedUrl = [url stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters];
Jesus…this took me way too long to figure out
you saved me a night of wasting my time with this FU**ing Apple ios objective shit.
I own you a beer! Thank you!!
I got here by googling it.
Glad to help!
Jesus Christ that took a long time to solve. You’re a life saver.
SHould there be backslash before the second quote in the first Line?
What I’m missing in following code.
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *charactersToEscape = @”!*'();:@&=+$,/?%#[]”;
NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:charactersToEscape] invertedSet];
NSString *encodedUrl = [@”test=” stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters];
NSLog (@”hello world”);
[pool drain];
return 0;
}
I m getting error:
: Uncaught exception NSInvalidArgumentException, reason: -[NSConstantString stringByAddingPercentEncodingWithAllowedCharacters:]: unrecognized selector sent to instance 0x601270