您的位置:首页 > 其它

[NSURL URLWithString:] 返回nil

2014-08-14 16:17 706 查看
具体问题原因是url中输入的有中文,那么这个就看作非法的字符无法识别。这种的必须使用post方式来发送消息。具体为:

tmp = mainurl;
[parameters appendString:key];
[parameters appendString:value];

NSURL * downloadUrl = [NSURL URLWithString:self.strURL];
NSMutableURLRequest *requestL = [NSMutableURLRequest requestWithURL:downloadUrl
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:60.0];
[requestL setHTTPMethod:@"POST"];
NSString *postString = parameters;
[requestL setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"the post body is %@",[NSString stringWithFormat:@"%@", postString]);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: