zoukankan      html  css  js  c++  java
  • 20160220 网络请求

    //用药宝典

    - (void)MedicaRequest

    {

        [MBProgressHUD showHUDAddedTo:self.view animated:YES];

        AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc]init];

        manager.responseSerializer = [AFHTTPResponseSerializer serializer];

        manager.responseSerializer.acceptableContentTypes=[NSSet setWithObjects:@"text/html",@"text/plain",@"text/json",@"application/json",nil];

        NSString *mediaUrl = [NSString stringWithFormat:@"%@medicine",Public_URL];

        NSMutableDictionary *mutdic = [NSMutableDictionary dictionary];

        mutdic[@"page"] = [NSString stringWithFormat:@"%d",number];

        [manager POST:mediaUrl parameters:mutdic success:^(AFHTTPRequestOperation *operation, id responseObject) {

            NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:operation.responseData options:NSJSONReadingAllowFragments error:nil];

            

            NSString *code=[NSString stringWithFormat:@"%@",dic[@"code"]];

            NSLog(@"code  ==%@",code);

            if ([code isEqualToString:@"1"]) {

                [_MedicaMutarray addObjectsFromArray:dic[@"data"]];

    //            [_MedicatableView reloadData];

                [MBProgressHUD hideHUDForView:self.view animated:YES];

            }else{

            

                [self showHint:@"查询失败!"];

                [MBProgressHUD hideHUDForView:self.view animated:YES];

            

            }

            

            

            if (_MedicaMutarray.count>0) {

                imagershuju.hidden = YES;

                tiwuxianLab.hidden = YES;

                

            }else{

                imagershuju.hidden = NO;

                tiwuxianLab.hidden = NO;

            }

            [_MedicatableView reloadData];

            [MBProgressHUD hideHUDForView:self.view animated:YES];

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

    //        [MBProgressHUD hideHUDForView:self.view animated:YES];

            if (_MedicaMutarray.count>0) {

                imagershuju.hidden = YES;

                tiwuxianLab.hidden = YES;

                

            }else{

                imagershuju.hidden = NO;

                tiwuxianLab.hidden = NO;

            }

           [_MedicatableView reloadData];

            [MBProgressHUD hideHUDForView:self.view animated:YES];

        }];

    }

  • 相关阅读:
    关于Excel无法打开,因为文件格式或文件扩展名无效的解决方法
    SpringBoot整合rabbitmq
    异步线程池的使用
    java1.8新特性之stream流式算法
    hashMap的底层实现
    redis底层设计(五)——内部运作机制
    redis底层设计(四)——功能的实现
    redis底层设计(三)——redis数据类型
    redis底层设计(二)——内存映射数据结构
    redis底层设计(一)——内部数据结构
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5203686.html
Copyright © 2011-2022 走看看