| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- //
- // 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"
- #import "RASettingAboutCell.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;
- case RASettingTypeAbout: {
- cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingAboutCell" forIndexPath:indexPath];
- }
- break;
- default: {
- cell = [RASettingBaseCell new];
- }
- break;
- }
-
- [cell setModel:model];
- return cell;
- }
- @end
|