I made a CustomView that extends NSView. And a class MyCLass that contains a CustomView.
In below code CustomView viewA is showing correctly. But that same view through MyClass wont show. I got no error but there is nothing on the screen. Anybody knows why?
CustomView* viewA = [[CustomView alloc]initWithFrame:NSMakeRect(0, 0, 600, 400)];
MyClass *foo;
[foo setFooView:[[CustomView alloc]initWithFrame:NSMakeRect(0, 0, 600, 400)]];
// or [foo setFooView:viewA];
[[self.window contentView] addSubview:viewA]; //IS SHOWING
[[self.window contentView] addSubview:foo.fooview]; //DOES NOT SHOW?
.h file of MyClass
#import "CustomView.h"
@interface MyClass : NSObject
{
CustomView *fooview;
}
-(CustomView *) fooview;
-(void) setFooView:(CustomView *)input;
@end
.m file of MyClass
#import "MyClass.h"
@implementation MyClass
- (CustomView *)fooview {
return fooview;
}
-(void) setFooView:(CustomView *)input
{
fooview = input;
}
@end
Are you actually creating an instance of
MyClassanywhere? It appears as if you’re putting theCustomViewinto a nil object.