Load Nib File Easily
+ (id)viewFromNibFileOfNibNameEqualClassNameWithOwner:(id)owner{
Class cls = [self class];
NSString *className = NSStringFromClass(cls);
NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:className owner:owner options:NULL];
NSEnumerator *nibEnumerator = [nibContents objectEnumerator];
NSObject* nibItem = nil;
id object = nil;
while ((nibItem = [nibEnumerator nextObject]) != nil) {
if ([nibItem isKindOfClass:cls]) {
object = nibItem;
break;
}
}
return object;
}
Sample use
if (cell == nil) {
cell = [BranchesAtmDetailTableCell viewFromNibFileOfNibNameEqualClassNameWithOwner:self];
}
Written by vsching
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Objective-c
Authors
Related Tags
#objective-c
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#