123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- //
- // 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
|