Skip to content

Commit

Permalink
Fix the unnecessary unload function call when view will appear.
Browse files Browse the repository at this point in the history
  • Loading branch information
xingheng committed Dec 7, 2018
1 parent a377676 commit b12de8b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions DSBaseViewController/DSBaseViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ - (void)viewWillAppear:(BOOL)animated
self.fReceivedMemoryWarning = NO;
} else {
if ([self _hasInvalidStatusData]) {
[self.delegate tearDown:self];
[self.delegate loadDataForController:self];
[self _loadDataSafely];
}
}
}
Expand Down Expand Up @@ -91,7 +90,7 @@ - (void)viewDidDisappear:(BOOL)animated
}

if ([self _hasInvalidStatusData]) {
[self.delegate tearDown:self];
[self _unloadDataSafely];
}
}

Expand All @@ -102,10 +101,8 @@ - (void)didReceiveMemoryWarning
if (!self.visible) {
DDLogVerbose(@"%@ - received memory warning.", [self class]);

if ([self.delegate respondsToSelector:@selector(tearDown:)]) {
[self.delegate tearDown:self];
self.fReceivedMemoryWarning = YES;
}
[self _unloadDataSafely];
self.fReceivedMemoryWarning = YES;
}
}

Expand Down Expand Up @@ -180,6 +177,13 @@ - (void)_loadDataSafely
}
}

- (void)_unloadDataSafely
{
if ([self.delegate respondsToSelector:@selector(loadDataForController:)]) {
[self.delegate tearDown:self];
}
}

- (BOOL)_hasInvalidStatusData
{
BOOL result = NO;
Expand Down

0 comments on commit b12de8b

Please sign in to comment.