• [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]);
            


  • 相关阅读:
    List中的get(i)
    报空指针异常
    json数据请求
    springmvc中的字典表
    json的解析
    httpClient返回的数据类型,怎么弄
    java中webService
    红外遥控协议(NEC)
    很奇怪的GPIO地址
    emacs命令备忘
  • 原文地址:https://www.cnblogs.com/lisa090818/p/3912832.html
Copyright © 2020-2023  润新知