URL Encode NSString in Objective-C

It’s very easy to URL Encode an NSString in Objective-C (i.e. make a string safe to send using a GET request).  Simply do this:

NSString* escapedUrlString =[unescapedString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

Then just use the escapedUrlString in your NSURL object and you’re on your way.

你可能感兴趣的:(object,String,url)