Skip to content

Instantly share code, notes, and snippets.

@edopelawi
Last active September 26, 2015 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edopelawi/4fe0f381c40d67f6a166 to your computer and use it in GitHub Desktop.
Save edopelawi/4fe0f381c40d67f6a166 to your computer and use it in GitHub Desktop.
RenamedVariableViewDidLoad with one level of abstraction, plus some fake "stale data validation".
@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