123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- //
- // FKIdCardManageViewModel.m
- // FirstLink
- //
- // Created by jack on 15/11/25.
- // Copyright © 2015年 FirstLink. All rights reserved.
- //
- #import "FKIdCardManageViewModel.h"
- @implementation FKIdCardManageViewModel
- - (FKIdCardItem *)idCardItemAtIndex:(NSUInteger)index{
- if (index < self.idCardArray.count ) {
- return self.idCardArray[index];
- }
- return nil;
- }
- - (void)setDefaultAtIndex:(NSUInteger)index{
- if (index < self.idCardArray.count) {
- for (FKIdCardItem *item in self.idCardArray) {
- item.isDefault = @"0";
- }
-
- FKIdCardItem *targetItem = [self idCardItemAtIndex:index];
- if (targetItem) targetItem.isDefault = @"1";
- }
- }
- - (NSUInteger)currentDefaultIndex{
- __block NSUInteger index = 0;
- [self.idCardArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- FKIdCardItem *item = (FKIdCardItem *)obj;
- if ([item isKindOfClass:[FKIdCardItem class]] && [item checkIsDefault] == YES) index = idx;
- }];
-
- return index;
- }
- - (void)deleteIdCardAtIndex:(NSUInteger)index{
- if (index < self.idCardArray.count) {
- NSMutableArray *arrayM = [NSMutableArray arrayWithArray:self.idCardArray];
- [arrayM removeObjectAtIndex:index];
- self.idCardArray = arrayM;
- }
- }
- @end
|