Last active
December 14, 2015 07:59
-
-
Save bjhomer/5054702 to your computer and use it in GitHub Desktop.
Pattern for -init methods of controllers designed in a storyboard
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
- (id)init | |
{ | |
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainInterface" bundle:nil]; | |
self = [storyboard instantiateViewControllerWithIdentifier:@"MyControllerIdentifier"]; | |
// Set up ivars here. 'self' won't be nil; if it is, you passed an invalid identifier | |
// and UIKit would have thrown an exception anyway. | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This results in an extra alloc.
How about:
instead?