// // FKHotSaleViewModel.m // FirstLink // // Created by ascii on 2017/6/10. // Copyright © 2017年 FirstLink. All rights reserved. // #import "FKHotSaleViewModel.h" @implementation FKHotSaleViewModel - (NSArray *)sectionTitles { NSMutableArray *array = [NSMutableArray array]; for (FKHotSaleCategoryModel *model in self.categoryArray) { [array addObject:model.name]; } return array; } - (NSArray *)hotSaleModelArrayWithSectionIndex:(NSInteger)index { if (index < self.categoryArray.count) { FKHotSaleCategoryModel *category = self.categoryArray[index]; return self.hotSaleDict[category.cID]; } return nil; } - (void)appendHotSaleList:(NSArray *)array { FKHotSaleModel *model = array.firstObject; if (model) { NSMutableArray *mutArray = [self.hotSaleDict valueForKey:model.cID]; if (mutArray == nil) { mutArray = [NSMutableArray array]; } [mutArray addObjectsFromArray:array]; [self.hotSaleDict setValue:mutArray forKey:model.cID]; } } - (void)resetHotSaleList:(NSArray *)array { FKHotSaleModel *model = array.firstObject; if (model) { NSMutableArray *mutArray = [NSMutableArray array]; [mutArray addObjectsFromArray:array]; [self.hotSaleDict setValue:mutArray forKey:model.cID]; } } #pragma mark - Property - (NSMutableDictionary *> *)hotSaleDict { if (!_hotSaleDict) { _hotSaleDict = [NSMutableDictionary dictionary]; } return _hotSaleDict; } @end