URL Encode NSString in Objective-C

来源:互联网 发布:ubuntu p2p下载工具 编辑:程序博客网 时间:2024/06/06 01:44

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.

原创粉丝点击