Skip to content

Instantly share code, notes, and snippets.

@cmkilger
Created March 2, 2012 17:48
Show Gist options
  • Save cmkilger/1959950 to your computer and use it in GitHub Desktop.
Save cmkilger/1959950 to your computer and use it in GitHub Desktop.
loadView
- (void)loadView {
if (!self.nibName) {
NSString * nibName = nil;
NSString * className = NSStringFromClass([self class]);
if ([className hasSuffix:@"Controller"])
nibName = [className substringToIndex:[className rangeOfString:@"Controller" options:NSBackwardsSearch].location];
if (!nibName || ![self.nibBundle pathForResource:nibName ofType:@"nib"])
nibName = className;
if ([self.nibBundle pathForResource:nibName ofType:@"nib"]) {
[self.nibBundle loadNibNamed:nibName owner:self options:nil];
return;
}
}
[super loadView];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment