RASettingSectionModel.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // RASettingSectionModel.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/9/12.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RASettingSectionModel.h"
  9. #import "RASettingOptionModel.h"
  10. #import "RASettingSwitchModel.h"
  11. #import "RASettingActionModel.h"
  12. #import "RASettingAboutModel.h"
  13. @implementation RASettingSectionModel
  14. - (void)setValue:(id)value forUndefinedKey:(NSString *)key {
  15. }
  16. - (void)setSettings:(NSArray<RASettingBaseModel *> *)settings {
  17. if (!settings) {
  18. _settings = nil;
  19. return;
  20. }
  21. NSMutableArray<RASettingBaseModel *> *arr = [NSMutableArray array];
  22. for (NSDictionary *value in settings) {
  23. RASettingType type = [[value objectForKey:@"type"] intValue];
  24. RASettingBaseModel *model = nil;
  25. switch (type) {
  26. case RASettingTypeOption: {
  27. model = [RASettingOptionModel new];
  28. }
  29. break;
  30. case RASettingTypeSwitch: {
  31. model = [RASettingSwitchModel new];
  32. }
  33. break;
  34. case RASettingTypeAction: {
  35. model = [RASettingActionModel new];
  36. }
  37. break;
  38. case RASettingTypeAbout: {
  39. model = [RASettingAboutModel new];
  40. }
  41. break;
  42. default:
  43. break;
  44. }
  45. if (model) {
  46. [model setValuesForKeysWithDictionary:value];
  47. [arr addObject:model];
  48. }
  49. }
  50. _settings = arr;
  51. }
  52. @end