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

  • 相关阅读:
    杨辉三角
    100以内的素数
    九九
    MyDate
    计算器
    100以内素数
    杨辉三角形
    九九乘法表
    窗口关闭事件
    计算器界面
  • 原文地址:https://www.cnblogs.com/fanwenzheIOS/p/4922451.html
Copyright © 2020-2023  润新知