iOS : How to do proper URL encoding?

后端 未结 10 1901
一整个雨季
一整个雨季 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:38

    It's very simple to encode the URL in iPhone. It is as following

    NSString* strURL = @"http://somedomain.com/data/Témp Page - Open.html";
    
    NSURL* url = [NSURL URLWithString:[strURL stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    

    It's a perfect way to encode the URL, I am using it and it's perfectly work with me.

    Hope it will help you!!!

提交回复
热议问题