CJADataSource 0.0.9

CJADataSource 0.0.9

测试测试
语言语言 Obj-CObjective C
许可证 MIT
发布时间最新发布2015年9月

Carl Jahn 维护。



  • 作者
  • Carl Jahn

每个人都在编写自己的基于 block 的 TableView/CollectionView/PageViewController DataSource,所以这是我的。

用法

只需添加

pod 'CJADataSource'

到您的 Podfile 并使用 #import <CJADataSource/CJADataSource> 导入所需的文件
或者直接将 CJADataSource 文件夹中的文件包含到您的项目中。

示例

UITableView *tableView = [[UITableView alloc] initWithFrame: CGRectMake(0, 0, 1, 1)];
...
...
[self.view addSubview: self.tableView];

NSDictionary *identifiers = @{ @"UITableViewCell" : [UITableViewCell class] };

NSArray *items = @[@"Item 1", @"Item 2", @"Item 3", @"Item 4"];
CJAArrayDatasource *datasource = [[CJAArrayDatasource alloc] initWithItems:items
                                        tableViewIdentifiersAndCellClasses:identifiers];


datasource.configureCellBlock = ^(UITableView *tableView, NSIndexPath *indexPath, UITableViewCell *cell, NSString *text){
  cell.textLabel.text = text;
};

datasource.cellClickedBlock = ^(UITableView *tableView, NSIndexPath *indexPath, NSString *text){
  NSLog(@"%@", text);
};

datasource.tableView = self.tableView;

待办事项

  • 添加单元测试
  • 支持 CollectionView
  • 更新文档

许可证

许可证