RASettingViewController+TableDataSource.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #import "RASettingAboutCell.h"
  17. @implementation RASettingViewController (TableDataSource)
  18. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  19. return self.sections.count;
  20. }
  21. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  22. RASettingSectionModel *sectionModel = [self.sections objectAtIndex:section];
  23. return sectionModel.settings.count;
  24. }
  25. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  26. RASettingSectionModel *sectionModel = [self.sections objectAtIndex:indexPath.section];
  27. RASettingBaseModel *model = [sectionModel.settings objectAtIndex:indexPath.row];
  28. RASettingBaseCell *cell = nil;
  29. switch (model.type) {
  30. case RASettingTypeOption: {
  31. cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingOptionCell" forIndexPath:indexPath];
  32. }
  33. break;
  34. case RASettingTypeSwitch: {
  35. cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingSwitchCell" forIndexPath:indexPath];
  36. }
  37. break;
  38. case RASettingTypeAction: {
  39. cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingActionCell" forIndexPath:indexPath];
  40. }
  41. break;
  42. case RASettingTypeAbout: {
  43. cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingAboutCell" forIndexPath:indexPath];
  44. }
  45. break;
  46. case RASettingTypeLink: {
  47. cell = [tableView dequeueReusableCellWithIdentifier:@"RASettingLinkCell" forIndexPath:indexPath];
  48. }
  49. break;
  50. default: {
  51. cell = [RASettingBaseCell new];
  52. }
  53. break;
  54. }
  55. [cell setModel:model];
  56. return cell;
  57. }
  58. @end