// // CollectionViewController.m // FirstLink // // Created by unicode on 14-10-13. // Copyright (c) 2014年 FirstLink. All rights reserved. // #import "CollectViewModel.h" #import "FLRequestHelper.h" @interface CollectViewModel () @end @implementation CollectViewModel #pragma mark - Function - (NSMutableArray *)itemsArray { if (!_itemsArray) { _itemsArray = [NSMutableArray array]; } return _itemsArray; } - (NSInteger)numberOfRows { return self.itemsArray.count; } - (CollectItem *)itemAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row < self.itemsArray.count) { return self.itemsArray[indexPath.row]; } return nil; } - (NSInteger)removeNotCollectItem { NSMutableArray *removeArray = [NSMutableArray array]; for (CollectItem *item in self.itemsArray) { if (!item.isCollect) { [removeArray addObject:item]; } } [self.itemsArray removeObjectsInArray:removeArray]; return removeArray.count; } - (void)setCollectItem:(NSString *)targetID status:(BOOL)isCollect { for (CollectItem *item in self.itemsArray) { if ([item.itemID isEqualToString:targetID]) { item.isCollect = isCollect; } } } @end