- 實(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"];
- 提示用戶請(qǐng)求
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
打印
dic
獲取接口請(qǐng)求
[[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ā)送搜索請(qǐng)求失敗");
if ([model.responseDic[@"error_code"] intValue] == 0) {
// [[UIToast makeText:@"搜索成功,請(qǐng)查收!"] show];
_dataSource = [[NSArray alloc]init];
if (![model.responseDic[@"restaurantList"] isKindOfClass:[NSNull class]]) {
_dataSource = model.responseDic[@"restaurantList"];
}
[_tableView reloadData];
}else{
[[UIToast makeText:@"請(qǐng)求失敗"] show];
}
}
}];
- 打印
responseDic
- 并調(diào)用
#import "UIToast.h"
讓其成功失敗給與用戶顯示阻课。