iOS : How to do proper URL encoding?

后端 未结 10 1879
一整个雨季
一整个雨季 2020-12-13 19:20

I\'m unable to open a URL into UIWebView so I\'ve seached & found that I need to encode URL, so I tried to encode it but, I\'ve facing problem in URL encodi

10条回答
  •  囚心锁ツ
    2020-12-13 19:43

    This may useful to someone who's reach to this question for URL encoding, as my question likely different which has been solved and accepted, this is the way I used to do encoding,

    -(NSString *)encodeURL:(NSString *)urlString
    {
        CFStringRef newString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)urlString, NULL, CFSTR("!*'();:@&=+@,/?#[]"), kCFStringEncodingUTF8);
        return (NSString *)CFBridgingRelease(newString);
    }
    

提交回复
热议问题