Skip to content

Commit 3f1cbca

Browse files
committed
判断 pro 列表变化的一个修改
1 parent 3fd0a4e commit 3f1cbca

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

Coding_iOS/Controllers/RootControllers/MyTask_RootViewController.m

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -236,21 +236,10 @@ - (void)loadTasksLabels {
236236
}
237237

238238
- (void)configSegmentControlWithData:(Projects *)freshProjects {
239-
240-
BOOL dataHasChanged = NO;
241-
for (Project *freshPro in freshProjects.list) {
242-
BOOL hasFreshPro = NO;
243-
for (Project *oldPro in self.myProjectList) {
244-
if (freshPro.id.integerValue == oldPro.id.integerValue) {
245-
hasFreshPro = YES;
246-
break;
247-
}
248-
}
249-
if (!hasFreshPro) {
250-
dataHasChanged = YES;
251-
break;
252-
}
253-
}
239+
NSMutableSet *oldProSet = [[NSSet alloc] initWithArray:[self.myProjectList valueForKey:@"id"]].mutableCopy;
240+
NSMutableSet *freshProSet = [[NSSet alloc] initWithArray:[freshProjects.list valueForKey:@"id"]].mutableCopy;
241+
[oldProSet removeObject:@(-1)];//代表「全部项目」的 id 号
242+
BOOL dataHasChanged = ![oldProSet isEqualToSet:freshProSet];
254243

255244
if (dataHasChanged) {
256245
self.myProjectList = [[NSMutableArray alloc] initWithObjects:[Project project_All], nil];

0 commit comments

Comments
 (0)