Skip to content

Commit 2802fe6

Browse files
committed
任务列表性能优化
1 parent 07f4d7c commit 2802fe6

2 files changed

Lines changed: 10 additions & 21 deletions

File tree

Coding_iOS/Models/Tasks.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ typedef NS_ENUM(NSInteger, TaskEntranceType){
2525
@property (readwrite, nonatomic, strong) NSNumber *page, *pageSize, *totalPage, *totalRow;
2626
@property (readwrite, nonatomic, strong) NSString *backend_project_path;//从Project中取来的
2727
@property (readwrite, nonatomic, strong) NSMutableArray *list;
28+
@property (strong, nonatomic) NSArray *doneList, *processingList;
2829
@property (readwrite, nonatomic, strong) User *owner;
2930
@property (readwrite, nonatomic, strong) Project *project;
3031
@property (readwrite, nonatomic, strong) NSDictionary *propertyArrayMap;
@@ -36,9 +37,6 @@ typedef NS_ENUM(NSInteger, TaskEntranceType){
3637
+ (Tasks *)tasksWithPro:(Project *)project owner:(User *)owner queryType:(TaskQueryType)type;
3738
+ (Tasks *)tasksWithPro:(Project *)project queryType:(TaskQueryType)type;
3839

39-
- (NSArray *)doneList;
40-
- (NSArray *)processingList;
41-
4240
- (NSString *)queryType;
4341
- (NSDictionary *)toParams;
4442
- (NSString *)toRequestPath;

Coding_iOS/Models/Tasks.m

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,6 @@ + (Tasks *)tasksWithPro:(Project *)project queryType:(TaskQueryType)type{
4040
tasks.entranceType = TaskEntranceTypeMine;
4141
return tasks;
4242
}
43-
- (NSArray *)processingList{
44-
if (!_list) {
45-
return [NSArray array];
46-
}
47-
NSArray *list;
48-
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"status.intValue == %d", 1];
49-
list = [self.list filteredArrayUsingPredicate:predicate];
50-
return list ? list : [NSArray array];
51-
}
52-
- (NSArray *)doneList{
53-
if (!_list) {
54-
return [NSArray array];
55-
}
56-
NSArray *list;
57-
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"status.intValue == %d", 2];
58-
list = [self.list filteredArrayUsingPredicate:predicate];
59-
return list ? list : [NSArray array];
60-
}
6143

6244
- (NSString *)queryType{
6345
NSString *queryType;
@@ -135,6 +117,15 @@ - (void)configWithTasks:(Tasks *)resultA{
135117
}
136118

137119
self.canLoadMore = self.page.intValue < self.totalPage.intValue;
120+
121+
if (_list.count > 0) {
122+
NSPredicate *donePredicate = [NSPredicate predicateWithFormat:@"status.intValue == %d", 2];
123+
NSPredicate *processingPredicate = [NSPredicate predicateWithFormat:@"status.intValue == %d", 1];
124+
_doneList = [self.list filteredArrayUsingPredicate:donePredicate];
125+
_processingList = [self.list filteredArrayUsingPredicate:processingPredicate];
126+
}else{
127+
_doneList = _processingList = nil;
128+
}
138129
}
139130

140131
@end

0 commit comments

Comments
 (0)