我想像这样构建一个NSURLRequest:
NSString *str = @"http://example.com?format=xml&data=<token>123456</token>";
NSURL *url = [[NSURL alloc] initWithString:str];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
似乎NSURL不支持XML格式参数data=<token>123456</token>
,
所以它返回nil。
但是我必须在我的UIWebView中加载这种url。
答案 0 :(得分:1)
如果你&#34;逃避&#34;怎么办?那些使用stringByAddingPercentEscapesUsingEncoding:
的特殊字符?
NSString *str = @"http://example.com?format=xml&data=<token>123456</token>";
NSString *escaped = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:escaped]];