Create a gist now

Instantly share code, notes, and snippets.

Cocoa (Touch) templates for common subclasses
#import "XQCView.h"
@interface XQCView ()
@end
@implementation XQCView
#pragma mark - Memory Management
- (void)dealloc
{
}
#pragma mark - Setup & Init
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
- (void)setup
{
[self setupSubviews];
[self setupLayout];
}
#pragma mark - Setup & Init (Private)
- (void)setupSubviews
{
}
- (void)setupLayout
{
}
@end
#import "XQCViewController.h"
#import "XQCView.h"
@interface XQCViewController ()
@end
@implementation XQCViewController
#pragma mark - Memory Management
- (void)dealloc
{
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Setup & Init
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
[self setup];
}
return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
[self setup];
}
return self;
}
- (void)setup
{
self.title = @"Example View Controller";
}
#pragma mark - View Lifecycle
- (void)loadView
{
XQCView *view = [[XQCView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.view = view;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment