使用节和行组织uitableviewdatasource的最佳方法是什么?

时间:2014-05-28 04:20:40

标签: ios objective-c uitableview

这似乎是一个非常基本的问题,但假设我有一个数据模型如下:

@interface MyModel
   @property (nonatomic, strong) NSNumber *index;
   @property (nonatomic, strong) NSNumber *sectionIndex;

   ...
@end

编写UITableView数据源函数非常简单:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

通过构建字典和逻辑来将索引路径映射到数据源对象。但是有没有一些Objective-c构造允许我在不编写逻辑的情况下这样做?我认为这个模型模式很常见,应该有一些我可以使用的Objective-c模式。

0 个答案:

没有答案
相关问题