No Description

FKBookReform.m 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // FKBookReform.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/4/28.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKBookReform.h"
  9. @implementation FKBookReform
  10. + (FKBookNormalViewModel *)parserBookNormalModelWithDict:(NSDictionary *)dict{
  11. if ([dict[@"data"] isKindOfClass:[NSDictionary class]]) {
  12. FKBookNormalViewModel *viewModel = [[FKBookNormalViewModel alloc]init];
  13. [viewModel mts_setValuesForKeysWithDictionary:dict[@"data"]];
  14. return viewModel;
  15. }
  16. return nil;
  17. }
  18. + (FKBookRecViewModel *)parserBookRecModelWithDict:(NSDictionary *)dict{
  19. if ([dict[@"data"] isKindOfClass:[NSDictionary class]]) {
  20. NSArray *dataArray = dict[@"data"][@"list"];
  21. if ([dataArray isKindOfClass:[NSArray class]] && dataArray.count > 0){
  22. NSMutableArray *arrayM = [NSMutableArray arrayWithCapacity:dataArray.count];
  23. for (NSDictionary *itemDict in dataArray) {
  24. FKBookRecItem *item = [[FKBookRecItem alloc]init];
  25. [item mts_setValuesForKeysWithDictionary:itemDict];
  26. [arrayM addObject:item];
  27. }
  28. FKBookRecViewModel *viewModel = [[FKBookRecViewModel alloc]init];
  29. viewModel.itemArray = arrayM;
  30. return viewModel;
  31. }
  32. }
  33. return nil;
  34. }
  35. @end