美文网首页
返回接口相关

返回接口相关

作者: 必须这么打 | 来源:发表于2015-12-11 14:43 被阅读0次

  • 实例化个可变字典
  • 通过URL是拼接的,是一个宏和另个宏拼接而成的。
    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];
  • 打印dic

  • 获取接口请求

[[SetRequest sharedInstance]postRequestWithURL:URL(searchSupermarketList)
    postParems:dic content:^(NetWorkModel *model){
        [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
        if(model.error){
            [[UIToast makeText:@"发送失败"] show];
        }else{
            NSLog(@"发送搜索请求失败");
            if ([model.responseDic[@"error_code"] intValue] == 0) {
                //  [[UIToast makeText:@"搜索成功,请查收!"] show];
                _dataSource = [[NSArray alloc]init];
                if (![model.responseDic[@"restaurantList"] isKindOfClass:[NSNull class]]) {
                    _dataSource = model.responseDic[@"restaurantList"];
                }
                [_tableView reloadData];
            }else{
                [[UIToast makeText:@"请求失败"] show];
            }
        }
    }];
  • 打印responseDic
  • 并调用 #import "UIToast.h"让其成功失败给与用户显示。

相关文章

  • 返回接口相关

    实例化个可变字典 通过URL是拼接的,是一个宏和另个宏拼接而成的。 添加参数 提示用户请求 打印dic 获取接口请...

  • IOS-返回接口相关的

    实例化个可变字典 通过URL是拼接的,是一个宏和另个宏拼接而成的。 添加参数 提示用户请求 打印dic 获取接口请...

  • RobotFramework接口测试分享(二)

    进阶问题 1、接口返回:用户未登录——session处理 2、接口返回:验签失败——参数签名 3、接口返回:解密失...

  • 提示信息接口地址

    查询接口 返回数据格式: 更新数据接口 返回数据格式:

  • 通过ajax方式无闪烁实现文件下载的3种方式

    后端接口返回下载文件地址 ajax请求axios相关介绍https://www.jianshu.com/p/50d...

  • nginx返回504排查思路

    nginx返回504一般代表gateway timeout,也就是接口请求超时。 相关参数 NGINX 涉及到请求...

  • Spring IoC 的实现原理

    Class.forName(className):传入className返回与给定的字符串名称相关联类或接口的Cl...

  • Fiddler调试

    接口返回数据调试 1、改变接口返回数据测试页面 在接口返回参数前加断点 示例 以链家m站二手搜索小区接口为例 搜索...

  • 概述

    公共接口定义## 接口协议:所有接口的请求与应答均基于HTTP+JSON进行交换; 返回状态定义## 接口返回信息...

  • QQ空间音乐免费API接口说明

    这个接口是以JSON和XML做返回值处理的,默认为返回JSON。 API接口返回值为JSON: 返回为 JSON ...

网友评论

      本文标题:返回接口相关

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