I have my main window’s content view set like this:
newContentView = [[CutoutView alloc]initWithFrame:window.frame];
[window setContentView:newContentView];
[newContentView release];
Where CutoutView is the name of my subclass. Now I want to add a subview to it so I did the following,
filterView = [[FilterView alloc]initWithFrame:NSMakeRect(100, 100, 500, 500)];
[newContentView addSubview:filterView];
[filterView release];
that all works fine except now I want to call methods from my filterView subclass and I want to get it like this but it wont work.
FilterView *filter = [[NSApp delegate] contentView];
I read in the docs that by using contentView it only “returns the highest accessible NSView object in the window hierarchy” So I tried adding the following to the addSubview
[newContentView addSubview:filterView positioned:NSWindowAbove relativeTo:nil];
but that didnt work either any ideas as to what I need to do? Thanks!
The content view is really your CutoutView class so you should be using:
But two cleaner ways are:
1) Use IBOutlets to keep track of your views and assign them via IB.
2) Use tags:
then use: