RASettingViewController.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // RASettingViewController.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/9/11.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RASettingViewController.h"
  9. #import "RASettingSectionModel.h"
  10. @interface RASettingViewController ()
  11. {
  12. NSMutableArray<RASettingSectionModel *> *_sections;
  13. }
  14. @property (nonatomic,strong) IBOutlet UITableView *settingTableView;
  15. @end
  16. @implementation RASettingViewController
  17. + (instancetype)viewControllerFromStoryboard {
  18. RASettingViewController *settingVC = [[UIStoryboard storyboardWithName:@"setting" bundle:nil] instantiateViewControllerWithIdentifier:[self storyboardID]];
  19. return settingVC;
  20. }
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. // Do any additional setup after loading the view.
  24. [self configTableView];
  25. [self loadData];
  26. }
  27. - (void)didReceiveMemoryWarning {
  28. [super didReceiveMemoryWarning];
  29. // Dispose of any resources that can be recreated.
  30. }
  31. #pragma mark - Config
  32. - (void)configTableView {
  33. self.tableView.tableFooterView = [UIView new];
  34. self.tableView.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
  35. }
  36. #pragma mark - Getter
  37. - (UITableView *)tableView {
  38. return self.settingTableView;
  39. }
  40. - (NSArray<RASettingSectionModel *> *)sections {
  41. if (!_sections) {
  42. _sections = [NSMutableArray array];
  43. }
  44. return _sections;
  45. }
  46. #pragma mark - Data
  47. - (void)loadData {
  48. NSDictionary *json = [RADataProvider loadDataFromBundleFile:@"setting.json"];
  49. NSMutableArray *tmpArr = [NSMutableArray array];
  50. NSArray *sectionArr = [json objectForKey:@"sections"];
  51. for (NSDictionary *section in sectionArr) {
  52. RASettingSectionModel *model = [RASettingSectionModel new];
  53. [model setValuesForKeysWithDictionary:section];
  54. [tmpArr addObject:model];
  55. }
  56. NSMutableArray *sections = (NSMutableArray *)self.sections;
  57. [sections removeAllObjects];
  58. [sections addObjectsFromArray:tmpArr];
  59. [self.tableView reloadData];
  60. }
  61. @end