参数

作者: 王老板 | 来源:发表于2015-12-11 14:43 被阅读15次
    -(void)getData{
        //    //cityId:城市ID
        //    //lat:纬度
        //    //lng:经度
        //showType
        //sendPrice
        //defaultOeder
        NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
        NSDictionary *userInfo = [[NSUserDefaults standardUserDefaults] objectForKey:@"UserInfo"];
        [dic setValue:userInfo[@"supermaketName"] forKey:@"supermaketName"];
        [dic setValue:userInfo[@"tasteCategory"] forKey:@"tasteCategory"];
        [dic setValue:@"0411" forKey:@"ctiyId"];
        [dic setValue:[NSNumber numberWithDouble:121.517977] forKey:@"lng"];
        [dic setValue:[NSNumber numberWithDouble:38.8496481] forKey:@"lat"];
        [dic setValue:userInfo[@"type"] forKey:@"type"];
        [dic setValue:@"1" forKey:@"showType"];
        [MBProgressHUD showHUDAddedTo:self.view animated:YES];// 提示用户正在请求
        [[SetRequest sharedInstance]postRequestWithURL:URL(searchSupermarketList)
        postParems:dic content:^(NetWorkModel *model){
            
            [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
            if(model.error){
                
                NSLog(@"获取列表失败");
            }else{
                
                if ([model.responseDic[@"error_code"] intValue] == 0) {
                    
                    
                    _dataSource = model.responseDic[@"restaurantList"];
                    
                    [_tableView reloadData];
                    
                }
            }
        }];
    }
    
    • 有参数 有URL
    • 参数是
      //cityId:城市ID
      //lat:纬度
      //lng:经度
      //showType
      //sendPrice
      //defaultOeder
    • 打印model.responseDic为
    dishesList =     (
                    {
                classificationId = 10001;
                classificationName = "进口食品";
                dishName = "蒙牛纯牛奶1L";
                dishesState = 0;
                id = 1011611107;
                isPackages = 0;
                measureUnit = 9;
                name = "蒙牛纯牛奶1L";
                practiceSortId = 0;
                price = 8;
                recommendFlag = 0;
                smallImgPath = "http://dalianmohekeji.eicp.net:8102/repastmanage/upload/2015/08/19/16/50/20/small1916502378468.jpg";
                tasteSortId = 0;
                total = 0;
                vipPrice = 8;
      };
    }
    
    • URL 是利用拼接的方法

    • 一个宏拼接另一个宏

    • 把所有的数据放到字典里

    • dic = model.responseDic[@"UserInfo"];

    • 在页面中显示就取dic里面的值

     _TextFieldOne.text = _dic[@"clUserName"];
     _TextFieldTwo.text = _dic[@"telephone"];
     _TextFieldThree.text = _dic[@"address"];
    

    相关文章

      网友评论

          本文标题:参数

          本文链接:https://www.haomeiwen.com/subject/qduyhttx.html