iOS 调接口,传数据,xib跳转页面
2019-07-04 本文已影响0人
西红柿w
调接口
[Common showWaitingHUD:self.view title:@""];
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW,0), ^{
//从controller里写的接口的实例
BaseResponse *baseResponse = [BookWordController getWordList:self.md5code];
dispatch_async(dispatch_get_main_queue(), ^{
[Common hideAllHUD:self.view];
if (baseResponse != nil) {
if (baseResponse.result == SUCCESS) {
//将从接口获取到的数据放到wordLIst中,以后从wordList中引用
self.wordList = [Word mj_objectArrayWithKeyValuesArray:baseResponse.data];
[self.scanAddWordTableView reloadData];
} else {
[Common showTextHUDWithShortTime:self.view title:baseResponse.errmsg];
}
} else {
[AlertUtil showAlert:self title:@"错误" msg:@"请确认网络连接!"];
}
});
});
传数据
一般接口有的数据在页面上必须得传进去数据
example:
wordBookListVC.userId = self.userId;
wordBookListVC.wordList = wordList;
跳转页面
//NibName就是xib的名字去掉.xib
WordListViewController *wordBookListVC = [[WordListViewController alloc]initWithNibName:@"WordListViewController" bundle:[NSBundle mainBundle]];
wordBookListVC.userId = self.userId;
wordBookListVC.wordList = wordList;
[self.navigationController pushViewController:wordBookListVC animated:YES];