I create a XIB.
I create this class called MyCustomView and assign it to the XIB's File Owner.
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder:aDecoder];
if (self) [self load];
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) [self load];
return self;
}
- (void)load {
NSArray* topLevelObjects;
[[NSBundle mainBundle] loadNibNamed:@"MyCustomView"
owner:self
topLevelObjects:&topLevelObjects];
NSView* view;
for (id aView in topLevelObjects) {
if ([umaVista isKindOfClass:[NSView class]]) {
view = umaVista;
break;
}
}
[self addSubview:view];
view.frame = self.bounds;
}
I create a NSView on the main app.
I change that view to the MyCustomView.
I run the app. MyCustomView's initWithCoder does not run. initWithFrame does not run. awakeFromNib does not run.
Nothing happens.
Any ideas?