Skip to content

将dataSource分离出去,减小TableViewController的体积。

License

Notifications You must be signed in to change notification settings

xiaozhuxiong121/PGBaseDataSource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PGBaseDataSource

将dataSource分离出去,减小TableViewController的体积。

CocoaPods安装

pod 'PGBaseDataSource

一般普通的写法

#pragma mark UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PGTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellReuseIdentifier];
    return cell;
}

PGBaseDataSource的写法

//设置dataSource
self.tableView.dataSource = [PGBaseDataSource instance];
[[PGBaseDataSource instance] numberOfSectionsInTableView:^NSUInteger(UITableView *tableView) {
    return 1;
} numberOfRowsInSection:^NSUInteger(UITableView *tableView, NSInteger section) {
    return 10;
} cellForRowAtIndexPath:^UITableViewCell *(UITableView *tableView, NSIndexPath *indexPath) {
    PGTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellReuseIdentifier];
    return cell;
}];

Github Address

https://github.com/xiaozhuxiong121/PGBaseDataSource

About

将dataSource分离出去,减小TableViewController的体积。

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published