Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
coderZsq committed Feb 27, 2019
1 parent 7d24dd9 commit ca57a90
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ - (void)fetchDataSourceWithTitle:(NSString *)title type:(SQTrainingCapacityMuscl
NSAssert([NSThread isMainThread], @"main thread only, otherwise use lock to make thread safety");
SQTrainingCapacityDataBase * dataBase = [SQSqliteModelTool queryModels:self.dataBase.class columnName:@"key" relation:(ColumnNameToValueRelationTypeEqual) value:[NSString stringWithFormat:@"%ld-%@", type, title] uid:nil].firstObject;
if (!dataBase) {
[self addTrainingActionWithCompletion:nil];
[self addTrainingAction];
return;
}
NSMutableArray * dataSource = [NSMutableArray array];
Expand Down Expand Up @@ -104,13 +104,10 @@ - (void)storeDataSourceWithTitle:(NSString *)title type:(SQTrainingCapacityMuscl
[SQSqliteModelTool saveOrUpdateModel:self.dataBase uid:nil];
}

- (void)addTrainingActionWithCompletion:(void(^)(void))completion {
- (void)addTrainingAction {
SQTrainingCapacityCellPresenter * p = [SQTrainingCapacityCellPresenter new];
p.model = [SQTrainingCapacityModel new];
[self.data addObject:p];
if (completion) {
completion();
}
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

- (void)storeDataSourceWithTitle:(NSString *)title type:(SQTrainingCapacityMuscleType)type dataSource:(nonnull NSArray *)dataSource completion:(nonnull void (^)(void))completion;

- (void)addTrainingActionWithCompletion:(void(^)(void))completion;
- (void)addTrainingAction;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,8 @@ - (void)storeDataSourceWithTitle:(NSString *)title type:(SQTrainingCapacityMuscl
}];
}

- (void)addTrainingActionWithCompletion:(void (^)(void))completion {
[self.trainingCapacityDataService addTrainingActionWithCompletion:^{
if (completion) {
completion();
}
}];
- (void)addTrainingAction {
[self.trainingCapacityDataService addTrainingAction];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN

- (void)storeDataSourceWithTitle:(NSString *)title type:(SQTrainingCapacityMuscleType)type dataSource:(nonnull NSArray *)dataSource;

- (void)addTrainingActionWithCompletion:(void(^)(void))completion;
- (void)addTrainingAction;

- (NSArray *)fetchDataSource;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ - (NSArray *)fetchDataSourceFromDB {
}

- (void)didTouchNavigationBarAddButton {
__weak typeof(self) _self = self;
[self.interactor addTrainingActionWithCompletion:^{
[_self.view setupTableView];
}];
[self.interactor addTrainingAction];
[self.view setupTableView];
}

- (void)keyboardWillShow:(NSNotification *)sender {
Expand Down

0 comments on commit ca57a90

Please sign in to comment.