美文网首页
访问接口

访问接口

作者: 瞅你咋地 | 来源:发表于2015-12-11 14:43 被阅读0次
  • 首先创建一个Header File , 在其中写入URL

前两段代码为格式,因为URL开头的格式都是以前两段代码为开始,所以写入之后以后直接输入#define+URL就可以了。

#define IP @"http://dalianmohekeji.eicp.net:8102/repastmanage"
#define URL(api)   [ NSString stringWithFormat:@"%@%@",IP,api]
 #define ******* (输入URL)@"/clientAPI/searchRestaurantList.json"
-(void)getData{
    //    //cityId:城市ID
    //    //lat:纬度
    //    //lng:经度
    //showType
    //sendPrice
    // defaultOeder
   //实例化一个字典 
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    // 在字典中写入key
    NSDictionary *userInfo = [[NSUserDefaults standardUserDefaults] objectForKey:@"UserInfo"];
    //向dic中传值
    [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(*********输入URL)
    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];                
            }
        }
    }];
}


相关文章

  • 访问接口

    首先创建一个Header File , 在其中写入URL 前两段代码为格式,因为URL开头的格式都是以前两段代码为...

  • 访问接口

    有参数 有URL 参数是//cityId:城市ID//lat:纬度//lng:经度//showType//send...

  • 访问接口

    首先创建一个Header File ,在Header File中写入URL 因为URL开头格式都是以前两段代码为开...

  • laravel 事务与锁

    结论: 首先访问了test接口后再访问testName接口,发现testName接口没有一直处在request请求...

  • 访问权限

    2.1 public:接口访问权限 具有最大的访问权限,可以访问任何一个在classpath下的类、接口、异常...

  • redis+jwt+springBoot/springMvc逆向

    前提条件:访问接口先通过token拦截器(统一配置) 1.首次访问:访问登录接口,登录接口生成一个无期的token...

  • 用python为mysql实现restful接口

    点击访问 API接口

  • Action

    访问Servlet接口 ActionContext 实现接口ServletContextAware... Serv...

  • Hadoop | 访问接口

    1. 访问接口综述 2. 浏览器接口 3. 命令行接口

  • 移动架构--13.简单仿网络访问框架

    1.提供网络请求的包装类 2.网络访问结果回调接口 3.网络访问具体实现接口 4.供应用层回调的网络访问回调接口 ...

网友评论

      本文标题:访问接口

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