IOS-返回接口相關(guān)的


  • 實(shí)例化個(gè)可變字典
  • 通過URL是拼接的,是一個(gè)宏和另個(gè)宏拼接而成的。
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
  • 添加參數(shù)
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:@"發(fā)送失敗"] show];
        }else{
            NSLog(@"發(fā)送搜索請求失敗");
            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
  • 并調(diào)用 #import "UIToast.h"讓其成功失敗給與用戶顯示。
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • 218.241.181.202 wxhl60 123456 192.168.10.253 wxhl66 wxhl6...
    CYC666閱讀 1,443評論 0 6
  • 實(shí)例化個(gè)可變字典 通過URL是拼接的,是一個(gè)宏和另個(gè)宏拼接而成的。 添加參數(shù) 提示用戶請求 打印dic 獲取接口請...
    必須這么打閱讀 89評論 0 0
  • iOS開發(fā)系列--網(wǎng)絡(luò)開發(fā) 概覽 大部分應(yīng)用程序都或多或少會牽扯到網(wǎng)絡(luò)開發(fā),例如說新浪微博、微信等,這些應(yīng)用本身可...
    lichengjin閱讀 3,721評論 2 7
  • 1、截取字符串”20 | http://www.baidu.com”中,”|”字符前面和后面的數(shù)據(jù),分別輸出它們 ...
    強(qiáng)子ly閱讀 3,026評論 8 46
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 134,991評論 19 139