暫無描述

CollectViewModel.m 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // CollectionViewController.m
  3. // FirstLink
  4. //
  5. // Created by unicode on 14-10-13.
  6. // Copyright (c) 2014年 FirstLink. All rights reserved.
  7. //
  8. #import "CollectViewModel.h"
  9. #import "FLRequestHelper.h"
  10. @interface CollectViewModel ()
  11. @end
  12. @implementation CollectViewModel
  13. #pragma mark - Function
  14. - (NSMutableArray *)itemsArray {
  15. if (!_itemsArray) {
  16. _itemsArray = [NSMutableArray array];
  17. }
  18. return _itemsArray;
  19. }
  20. - (NSInteger)numberOfRows {
  21. return self.itemsArray.count;
  22. }
  23. - (CollectItem *)itemAtIndexPath:(NSIndexPath *)indexPath {
  24. if (indexPath.row < self.itemsArray.count) {
  25. return self.itemsArray[indexPath.row];
  26. }
  27. return nil;
  28. }
  29. - (NSInteger)removeNotCollectItem {
  30. NSMutableArray *removeArray = [NSMutableArray array];
  31. for (CollectItem *item in self.itemsArray) {
  32. if (!item.isCollect) {
  33. [removeArray addObject:item];
  34. }
  35. }
  36. [self.itemsArray removeObjectsInArray:removeArray];
  37. return removeArray.count;
  38. }
  39. - (void)setCollectItem:(NSString *)targetID status:(BOOL)isCollect {
  40. for (CollectItem *item in self.itemsArray) {
  41. if ([item.itemID isEqualToString:targetID]) {
  42. item.isCollect = isCollect;
  43. }
  44. }
  45. }
  46. @end