1. When using JSON to parse the service on the server side, a request URL must be provided. This URL sometimes needs to pass some parameters. If these parameters are English or numbers, the request will fail.
[Plain]
NSString * urlString = @ "http: // ·. aspx? N = James ";
UrlString = [urlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSURL * url = [NSURL urlWithString: urlString];
2. another common problem is the special character issue.
The following are some special characters of ASII (hexadecimal encoding)
+ Space % 2B in URL
The space in the space URL can be + or encoded as % 20
/Separate directories and subdirectories % 2F
? Separate the actual URL and parameter % 3F
% Special characters % 25
# Indicates bookmarks % 23
& Delimiter between parameters specified in the URL % 26
= The value of the specified parameter in the URL % 3D
Take space as an Example
[Plain]
NSString * urlString = @ "http: // ·. aspx? T = 20:00:30 ";
UrlString = [urlString replaceOccurrencesOfString: @ "" withString: @ "% 20"];
In this way, the Service will receive spaces correctly when it is accepted.