RASettingViewController+TableDataSource.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // RASettingViewController+TableDataSource.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/9/12.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RASettingViewController+TableDataSource.h"
  9. #import "RASettingSectionModel.h"
  10. #import "RASettingOptionModel.h"
  11. #import "RASettingSwitchModel.h"
  12. #import "RASettingActionModel.h"
  13. #import "RASettingOptionCell.h"
  14. #import "RASettingSwitchCell.h"
  15. #import "RASettingActionCell.h"
  16. @implementation RASettingViewController (TableDataSource)
  17. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  18. return self.sections.count;
  19. }
  20. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  21. RASettingSectionModel *sectionModel = [self.sections objectAtIndex:section];
  22. return sectionModel.settings.count;
  23. }
  24. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  25. RASettingSectionModel *sectionModel = [self.sections objectAtIndex:indexPath.section];
  26. RASettingBaseModel *model = [sectionModel.settings objectAtIndex:indexPath.row];
  27. RASettingBaseCell *cell = nil;
  28. switch (model.type) {
  29. case RASettingTypeOption: {
  30. cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingOptionCell" forIndexPath:indexPath];
  31. }
  32. break;
  33. case RASettingTypeSwitch: {
  34. cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingSwitchCell" forIndexPath:indexPath];
  35. }
  36. break;
  37. case RASettingTypeAction: {
  38. cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingActionCell" forIndexPath:indexPath];
  39. }
  40. break;
  41. default: {
  42. cell = [RASettingBaseCell new];
  43. }
  44. break;
  45. }
  46. [cell setModel:model];
  47. return cell;
  48. }
  49. @end