[NSURL URLWithString:] 返回nil

具体问题原因是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]);
        


posted @ 2014-08-14 16:17  如来藏  阅读(1016)  评论(0编辑  收藏  举报