Created
March 18, 2012 12:16
-
-
Save saturngod/2071090 to your computer and use it in GitHub Desktop.
URL Encode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation NSString (url) | |
-(NSString *)urlEncodedString { | |
return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8) autorelease]; | |
} | |
-(NSString *)urlDecodedString { | |
return [self stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
} | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSLog("Save this one %@",[myURL urlEncodedString]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! If you need to encode URLs online, you can use URLEncoder.io tool.