-(
NSString
*)urlEncoded:(
NSString
*)str {
NSString
*escapedUrlString = [str stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding
];
return
escapedUrlString;
}
-(
NSString
*)urlDecoded:(
NSString
*)str {
NSString
*cleanUrlString = [str stringByReplacingPercentEscapesUsingEncoding:
NSASCIIStringEncoding
];
return
cleanUrlString;
}
NSString
*devStr =
@"http://localhost/dri/json?foo=#bar&something=true&miscc=Foo bar!"
;
NSLog
(
@"devStr: %@"
,devStr);
NSString
*encString = [
self
urlEncoded:devStr];
NSLog
(
@"encString: %@"
,encString);
NSString
*decString = [
self
urlDecoded:encString];
NSLog
(
@"decString: %@"
,decString);