RASettingSectionModel.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #import "RASettingLinkModel.h"
  14. @implementation RASettingSectionModel
  15. - (void)setValue:(id)value forUndefinedKey:(NSString *)key {
  16. }
  17. - (void)setSettings:(NSArray<RASettingBaseModel *> *)settings {
  18. if (!settings) {
  19. _settings = nil;
  20. return;
  21. }
  22. NSMutableArray<RASettingBaseModel *> *arr = [NSMutableArray array];
  23. for (NSDictionary *value in settings) {
  24. RASettingType type = [[value objectForKey:@"type"] intValue];
  25. RASettingBaseModel *model = nil;
  26. switch (type) {
  27. case RASettingTypeOption: {
  28. model = [RASettingOptionModel new];
  29. }
  30. break;
  31. case RASettingTypeSwitch: {
  32. model = [RASettingSwitchModel new];
  33. }
  34. break;
  35. case RASettingTypeAction: {
  36. model = [RASettingActionModel new];
  37. }
  38. break;
  39. case RASettingTypeAbout: {
  40. model = [RASettingAboutModel new];
  41. }
  42. break;
  43. case RASettingTypeLink: {
  44. model = [RASettingLinkModel new];
  45. }
  46. break;
  47. default:
  48. break;
  49. }
  50. if (model) {
  51. [model setValuesForKeysWithDictionary:value];
  52. [arr addObject:model];
  53. }
  54. }
  55. _settings = arr;
  56. }
  57. @end