2024年6月
6ABCD.1
6ABCD.2
2024年5月
5ABCD.1
5ABCD.2
if (obj.requestState == RequestState_Success)
{
if (refreshType == RefreshType_First || refreshType == RefreshType_Down) {
[self.dataAry removeAllObjects];
[self.dataAllAry removeAllObjects];
}
NSArray *sssssssary = @[
@{
@"uid" : @"114",
@"score" : @"+3",
@"id" : @"40949004e4ff3ae4c94366b56fd9cd48c8.83542897",
@"reg_date" : @"2024-02-09 09:24:41",
@"month" : @"2024-02",
@"type" : @"0",
@"desc" : @"签到"
},
@{
@"uid" : @"114",
@"score" : @"+2",
@"id" : @"a6fcc1fa7010f368f3c866b46b28186f38.93572825",
@"reg_date" : @"2024-05-08 14:52:24",
@"month" : @"2024-05",
@"type" : @"0",
@"desc" : @"签到"
},
@{
@"uid" : @"114",
@"score" : @"+1",
@"id" : @"7a6334d41dd8124fce5d66b468c8856674.87679146",
@"reg_date" : @"2024-04-07 14:42:16",
@"month" : @"2024-04",
@"type" : @"0",
@"desc" : @"签到"
},
@{
@"uid" : @"114",
@"score" : @"+3",
@"id" : @"40949004e4ff3ae4c94366b56fd9cd48c8.83542867",
@"reg_date" : @"2024-03-09 09:24:41",
@"month" : @"2024-03",
@"type" : @"0",
@"desc" : @"签到"
}
];
if (refreshType == RefreshType_First || refreshType == RefreshType_Down) {
[self.dataAry removeAllObjects];
[self.dataAllAry removeAllObjects];
}
NSArray *aryData = [AServeSigninModel mj_objectArrayWithKeyValuesArray:obj.list];
if (aryData.count == 0) {
self.page--;
}
[self.dataAry removeAllObjects];
[self.dataAllAry addObjectsFromArray:aryData];
// 按时间分组排序
NSMutableArray *monthsetAry = [NSMutableArray array];
for (AServeSigninModel *model in self.dataAllAry)
{
[monthsetAry addObject:model.month];
}
NSSet *set = [NSSet setWithArray:monthsetAry];
NSMutableArray *array = [NSMutableArray arrayWithArray:[set allObjects]];
NSArray *newary = [[array reverseObjectEnumerator] allObjects];
for (int y = 0; y < newary.count; y++)
{
NSMutableArray *monthYAry = [NSMutableArray array];
NSString *monthStr = newary[y];
for (AServeSigninModel *signinmodel in self.dataAllAry)
{
if ([monthStr isEqualToString:signinmodel.month])
{
[monthYAry addObject:signinmodel];
}
}
[self.dataAry addObject:monthYAry];
}
[self.tableView reloadData];
核心
[self.dataAry removeAllObjects];
[self.dataAllAry addObjectsFromArray:aryData];
// 按时间分组排序
NSMutableArray *monthsetAry = [NSMutableArray array];
for (AServeSigninModel *model in self.dataAllAry)
{
[monthsetAry addObject:model.month];
}
NSSet *set = [NSSet setWithArray:monthsetAry];
NSMutableArray *array = [NSMutableArray arrayWithArray:[set allObjects]];
NSArray *newary = [[array reverseObjectEnumerator] allObjects];
for (int y = 0; y < newary.count; y++)
{
NSMutableArray *monthYAry = [NSMutableArray array];
NSString *monthStr = newary[y];
for (AServeSigninModel *signinmodel in self.dataAllAry)
{
if ([monthStr isEqualToString:signinmodel.month])
{
[monthYAry addObject:signinmodel];
}
}
[self.dataAry addObject:monthYAry];
}
[self.tableView reloadData];