RASettingSectionModel.m 1.4 KB

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