Skip to content

Instantly share code, notes, and snippets.

@johnclayton
Created March 18, 2013 20:11
Show Gist options
  • Save johnclayton/5190399 to your computer and use it in GitHub Desktop.
Save johnclayton/5190399 to your computer and use it in GitHub Desktop.
+ (NSString *)nibName {
return [self className];
}
+ (id) loadFromNib {
return [self loadFromNibWithOwner:self];
}
+ (id) loadFromNibWithOwner:(id)owner {
NSArray *theObjects = [[NSBundle mainBundle] loadNibNamed:[self nibName] owner:owner options:nil];
for (id theObject in theObjects) {
if ([theObject isKindOfClass:self])
return(theObject);
}
NSString *warning = [NSString stringWithFormat:@"Could not find object of class %@ in nib %@", [self class], [self nibName]];
FSQAssert(NO, warning);
return nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment