urldecode in objective-c

前端 未结 6 1752
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 10:19

I\'m dealing with an urlencoded string in objective-c. Is there a foundation function that actually reverse the urlENCODING?

The string received is like: K%FChlschr

6条回答
  •  萌比男神i
    2020-12-05 10:41

    Apple has depreacted stringByReplacingPercentEscapesUsingEncoding: since iOS9. Please use stringByRemovingPercentEncoding.

    The new method, Returns a new string made from the receiver by replacing all percent-encoded sequences with the matching UTF-8 characters.

    Example:

    NSString *encodedLink = @"hello%20world";
    NSString *decodedUrl = [encodedLink stringByRemovingPercentEncoding];
    NSLog (@"%@", decodedUrl);
    

    Output:

    hello world
    

提交回复
热议问题