zoukankan      html  css  js  c++  java
  • AFNetWorking 使用记录

    1.从一个URL  GET数据

    方法1:

            NSURL * url = [NSURL URLWithString:@"http://www.weather.com.cn/data/sk/101010100.html"];

            NSURLRequest * req = [NSURLRequest requestWithURL:url];

            AFHTTPRequestOperation * oper = [[AFHTTPRequestOperation alloc]initWithRequest:req];

            [oper setCompletionBlockWithSuccess:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {

                NSLog(@"succ:%@",operation.responseString);            

            } failure:^(AFHTTPRequestOperation * _Nonnull operation, NSError * _Nonnull error) {

                

                NSLog(@"fail:%@",error);

            }];

            

            NSOperationQueue * q = [NSOperationQueue new];

            [q addOperation:oper];

     

      方法2:      

            AFHTTPRequestOperationManager * m = [AFHTTPRequestOperationManager manager];

            m.responseSerializer = [AFHTTPResponseSerializer serializer];

            [m GET:@"http://www.weather.com.cn/data/sk/101010100.html" parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {

                

                NSLog(@"succ:%@",operation.responseString);

                

            } failure:^(AFHTTPRequestOperation * _Nonnull operation, NSError * _Nonnull error) {

                

                NSLog(@"fail:%@",error);

                

            }];

     

    2.POST

      

            AFHTTPRequestOperationManager * m = [AFHTTPRequestOperationManager manager];

            m.responseSerializer = [AFHTTPResponseSerializer serializer];

            

            NSMutableDictionary * d = [NSMutableDictionary new];

            [d setValue:@"白羊座" forKey:@"consName"];

            [d setValue:@"today" forKey:@"type"];

            [d setValue:@"8e8cb4ebeb7bbc14449fc62e6fe1ed7f" forKey:@"key"];

            

            

            [m POST:@"http://web.juhe.cn:8080/constellation/getAll" parameters:d success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {

                

                    

                    NSLog(@"succ:%@",operation.responseString);

                    

                } failure:^(AFHTTPRequestOperation * _Nonnull operation, NSError * _Nonnull error) {

                    

                    NSLog(@"fail:%@",error);

                    

                }];

     

        }

  • 相关阅读:
    【古曲】流水-古琴曲
    【文献阅读】基于特征的非局部均值图像去噪算法研究毕业论文
    【名言】后生看经书,须着看注疏及先儒解释,不然,执己见议论,恐入自是之域,便轻视古人。
    马氏距离(Mahalanobis distance)
    广义高斯分布(GGD)
    Lenna图-莱娜·瑟德贝里
    【机器学习】WIFI室内定位
    【matlab】生成列是0-255渐变的图像
    少笔画生僻字
    Gabor变换、Gabor滤波器
  • 原文地址:https://www.cnblogs.com/rollrock/p/5275898.html
Copyright © 2011-2022 走看看