9. iOS数组分组

2018-07-07  本文已影响0人  coder1003
- (NSMutableArray *)sortPhoto:(NSArray *)dataArr {

 NSMutableArray *dataArray = [NSMutableArray array];

[dataArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {

 SFAppointListModel *object = (SFAppointListModel *)obj;

 SFAppointListModel *group = ^SFAppointListModel *{

 for (SFAppointListModel *group in dataArray) {

 if ([group.dateStr isEqualToString:object.dateStr]) {

 return group;

                }

            }

 return nil;

        }();

 if (group == nil) {

[dataArray addObject:object];

        }

 else {

[group.bookResultDtos addObjectsFromArray:object.bookResultDtos];

        }

    }];

 return dataArray;

}
上一篇下一篇

猜你喜欢

热点阅读