zoukankan      html  css  js  c++  java
  • ISO 网络访问

    NSString *address = @"http://localhost/BookReaderData/BasicGetAndPost.php";

        

        

        

        // GET

    NSString *parameter = [NSString stringWithFormat:@"%@=%@", @"para", @"中文 Parameter Value"];

      // 将参数中的特殊字符串进行URL转译

    parameter = [parameter stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

       NSString *urlString = [NSString stringWithFormat:@"%@?%@", address, parameter];

       NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];

      

        NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];

        

        NSURLSessionDataTask *dataTash = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {

            

            if (error) {

                NSLog(@"%@", error);

            }

            else {

                NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

                NSLog(@"Response is %@", responseString);

            }

        }];

        [dataTash resume];

  • 相关阅读:
    跨域请求携带cookie
    vue keep-alive
    关于js replace 第二个参数时函数时,函数参数解析
    前端开发规范之CSS
    git命令集合(正在完善中...)
    怎么写jQuery的插件
    git命令集合
    GitHub创建静态网站预览方法
    正则表达式
    各种浏览器全屏模式的方法、属性和事件介绍
  • 原文地址:https://www.cnblogs.com/fanwenzheIOS/p/4922451.html
Copyright © 2011-2022 走看看