Skip to content

Instantly share code, notes, and snippets.

@hollance
Created December 29, 2011 13:42
Show Gist options
  • Save hollance/1534156 to your computer and use it in GitHub Desktop.
Save hollance/1534156 to your computer and use it in GitHub Desktop.
Loading view from nib
@implementation UIView (MHExtensions)
+ (id)mh_viewFromNibNamed:(NSString *)nibName owner:(id)ownerOrNil
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:nibName owner:ownerOrNil options:nil];
for (id object in nib)
{
if ([object isKindOfClass:[self class]])
return object;
}
return nil;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment