知识点数据太多

@property (strong, nonatomic) NSMutableArray  *havaSelectMarry; //多选选中的行

- (NSMutableArray *)havaSelectMarry
{
    if (!_havaSelectMarry) {
        self.havaSelectMarry = [NSMutableArray array];
    }
    return _havaSelectMarry;
}

- (void)confirmAction
{
    NSMutableArray *knowMarray = [NSMutableArray array];
    for (LMSNewKnowdgeModel *knowModel in self.havaSelectMarry) {
        if (knowModel.isSelect) {
            [knowMarray addObject:knowModel.departmentID];
        }
    }
    [[NSUserDefaults standardUserDefaults] setObject:knowMarray forKey:KPlanKnowdge];
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 计算选中人数列表
- (NSMutableArray *)calcullateTotalSelectedPersonAry:(NSArray *)dataAry isAllDepartment:(BOOL)isAll{

    __block NSMutableArray *mary = [NSMutableArray array];
    __weak typeof (self)weakSelf = self;
//    BOOL isAllSel = isAll;
    [dataAry enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if ([obj isKindOfClass:[LMSNewKnowdgeModel class]]) {
            LMSNewKnowdgeModel *model = (LMSNewKnowdgeModel *)obj;
            if (model.isSelect) {
                [mary addObject:model];
            }
            [model.children enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                if ([obj isKindOfClass:[LMSNewKnowdgeModel class]]) {
                    LMSNewKnowdgeModel *model = (LMSNewKnowdgeModel *)obj;
//                    if (isAllSel) {
//                        if (model.isSelect || isAllSel) {
//                            [mary addObject:model];
//                        }
//                    }else{
                        if (model.isSelect) {
                            [mary addObject:model];
                        }
//                    }
                }
            }];
            NSMutableArray *nextDepartment = [weakSelf calcullateTotalSelectedPersonAry:model.children isAllDepartment:NO];
            if (nextDepartment) {
                [mary addObjectsFromArray:nextDepartment];
            }
            NSArray *newarr = [mary valueForKeyPath:@"@distinctUnionOfObjects.self"];
            self.havaSelectMarry = [newarr copy];
        }
    }];
    return mary;
}

#pragma mark - 计选择人数,按钮赋值
-(void)getSelectedPeopleCount{
    //更新上层模型状态
//    [self changParentModelStatus];
//    [self changeAllModelStatusWithAry:self.orginalAry];
    
    NSArray *selectAry = [self calcullateTotalSelectedPersonAry:self.orginalAry isAllDepartment:NO];
    [self.selectedPeopleBtn setTitle:[NSString stringWithFormat:@"已选择%zd个知识点",self.havaSelectMarry.count] forState:UIControlStateNormal];
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值