RASettingViewController+TableDataSource.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. default: {
  47. cell = [RASettingBaseCell new];
  48. }
  49. break;
  50. }
  51. [cell setModel:model];
  52. return cell;
  53. }
  54. @end