| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- //
- // RASettingViewController+TableDataSource.m
- // Apex And Drivers
- //
- // Created by Jack on 2018/9/12.
- // Copyright © 2018年 USAI. All rights reserved.
- //
- #import "RASettingViewController+TableDataSource.h"
- #import "RASettingSectionModel.h"
- #import "RASettingOptionModel.h"
- #import "RASettingSwitchModel.h"
- #import "RASettingActionModel.h"
- #import "RASettingOptionCell.h"
- #import "RASettingSwitchCell.h"
- #import "RASettingActionCell.h"
- @implementation RASettingViewController (TableDataSource)
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return self.sections.count;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- RASettingSectionModel *sectionModel = [self.sections objectAtIndex:section];
- return sectionModel.settings.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- RASettingSectionModel *sectionModel = [self.sections objectAtIndex:indexPath.section];
- RASettingBaseModel *model = [sectionModel.settings objectAtIndex:indexPath.row];
-
- RASettingBaseCell *cell = nil;
-
- switch (model.type) {
- case RASettingTypeOption: {
-
- cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingOptionCell" forIndexPath:indexPath];
- }
- break;
- case RASettingTypeSwitch: {
-
- cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingSwitchCell" forIndexPath:indexPath];
- }
- break;
- case RASettingTypeAction: {
-
- cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingActionCell" forIndexPath:indexPath];
- }
- break;
- default: {
- cell = [RASettingBaseCell new];
- }
- break;
- }
-
- [cell setModel:model];
- return cell;
- }
- @end
|