懒加载的简单理解

懒加载是用到的时候再去加载比如

-(UITableView *)tableview{

    if (!_tableview) {

        _tableview = [[UITableView alloc]initWithFrame:[UIScreen mainScreen].bounds];

        self.tableview.delegate = self;

        self.tableview.dataSource = self;

        [self.view addSubview:self.tableview];

    }

    return _tableview;

}

 

这就是一个懒加载,调用的话就直接把这个方法用一下就可以了

比如在viewdidload里

[self.tableview reloadData];

posted @ 2016-06-03 18:11  偷吃的喵  阅读(117)  评论(0编辑  收藏  举报