Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a NSViewController's View if it is a custom class?

I use the following code to get my View out of my controller:

CollectionItemView *myView = [self view]; 

This works pretty well, but I get the warning Incompatible pointer types initializing CollectionItemView __strong with an expression of type NSView. I understand why i get this but is it okay to ignore it or should I overwrite the view property ?

chuck

like image 449
hakkurishian Avatar asked Nov 04 '22 20:11

hakkurishian


1 Answers

If you are sure that [self view] is CollectionItemView just do:

CollectionItemView *myView = (CollectionItemView*)[self view];

or (which is better) you can use:

id myView = [self view];
like image 124
Pavel Reznikov Avatar answered Nov 15 '22 05:11

Pavel Reznikov