123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- //
- // 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<FKHotSaleModel *> *)hotSaleModelArrayWithSectionIndex:(NSInteger)index {
- if (index < self.categoryArray.count) {
- FKHotSaleCategoryModel *category = self.categoryArray[index];
- return self.hotSaleDict[category.cID];
- }
- return nil;
- }
- - (void)appendHotSaleList:(NSArray<FKHotSaleModel *> *)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<FKHotSaleModel *> *)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<NSString *, NSMutableArray<FKHotSaleModel *> *> *)hotSaleDict {
- if (!_hotSaleDict) {
- _hotSaleDict = [NSMutableDictionary dictionary];
- }
- return _hotSaleDict;
- }
- @end
|