-
-
Save edopelawi/4fe0f381c40d67f6a166 to your computer and use it in GitHub Desktop.
RenamedVariableViewDidLoad with one level of abstraction, plus some fake "stale data validation".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface ViewController () | |
@property (nonatomic, assign) BOOL isCurrentDataStale; | |
@property (nonatomic, strong) NetworkService *service; | |
@property (nonatomic, assign) CGFloat yPositionOffset; | |
@property (nonatomic, assign) CGFloat defaultViewWidth; | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
[self configureViewRelatedProperties]; | |
[self addTopView]; | |
[self addBottomView]; | |
[self validateStaleData]; | |
} | |
#pragma mark - Setups - | |
- (void)configureViewRelatedProperties | |
{ | |
self.yPositionOffset = 64.0f; | |
self.defaultViewWidth = self.view.frame.size.width; | |
} | |
- (void)addTopView | |
{ | |
CGFloat topViewHeight = 100.0f; | |
UIView *topView = [self topViewWithHeight:topViewHeight]; | |
[self.view addSubview:topView]; | |
self.yPositionOffset += topViewHeight; | |
} | |
- (void)addBottomView | |
{ | |
CGFloat bottomViewHeight = 150.0f; | |
UIView *bottomView = [self bottomViewWithHeight:bottomViewHeight]; | |
[self.view addSubview:bottomView]; | |
} | |
- (void)validateStaleData | |
{ | |
if (self.isCurrentDataStale) { | |
[self.service retrieveData]; | |
} | |
} | |
// other details here... | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment