美文网首页工作生活
iOS 调接口,传数据,xib跳转页面

iOS 调接口,传数据,xib跳转页面

作者: 西红柿w | 来源:发表于2019-07-04 15:54 被阅读0次

    调接口

    [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];
    

    相关文章

      网友评论

        本文标题:iOS 调接口,传数据,xib跳转页面

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