Created
December 27, 2012 12:33
-
-
Save kluivers/4388037 to your computer and use it in GitHub Desktop.
Load a NSTableCellView from a NIB
This file contains hidden or 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
@interface NSTableCellView (JKNibLoading) | |
+ (instancetype) tableCellViewWithNibNamed:(NSString *)nibName owner:(id)owner; | |
@end | |
@implementation NSTableCellView (JKNibLoading) | |
+ (instancetype) tableCellViewWithNibNamed:(NSString *)nibName owner:(id)owner | |
{ | |
NSTableCellView *view = nil; | |
NSArray * topLevelObjects = nil; | |
NSNib * nib = [[NSNib alloc] initWithNibNamed:nibName bundle:nil]; | |
if (!nib || ![nib instantiateNibWithOwner:owner topLevelObjects:&topLevelObjects]) { | |
return nil; | |
} | |
for (id obj in topLevelObjects) { | |
if ([obj isKindOfClass:[self class]]) { | |
view = obj; | |
break; | |
} | |
} | |
return view; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This one works?