Skip to content

Instantly share code, notes, and snippets.

@numantariq
Last active September 7, 2017 14:40
Show Gist options
  • Save numantariq/b64e5f697b711338119ebbdd20e78d03 to your computer and use it in GitHub Desktop.
Save numantariq/b64e5f697b711338119ebbdd20e78d03 to your computer and use it in GitHub Desktop.
An example base class for View Controllers
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
//
#import <UIKit/UIKit.h>
@interface BaseViewController : UIViewController
- (void)commonInitializer;
@end
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
//
#import "BaseViewController.h"
@interface BaseViewController ()
@end
@implementation BaseViewController
#pragma mark - Initializer
- (instancetype)init {
self = [super init];
if (self) {
[self commonInitializer];
}
return self;
}
- (void)commonInitializer {
// Overwrite in subclasses
}
#pragma mark - Lifecycle Events
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark - Navigation & Status Bar
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment