I have a custom UIViewController and custom UIView. I’d like to override the viewcontroller.view property to return MyCustomUIView.
Right now I have:
@interface MyViewController : UIViewController { IBOutlet MyView* view; } @property (nonatomic, retain) IBOutlet MyView* view;
This compiles but I get a warning: property ‘view’ type does not match super class ‘UIViewController’ property type.
How do I alleviate this warning?
The short answer is that you don’t. The reason is that properties are really just methods, and if you attempt to change the return type, you get this:
Objective-C does not allow return type covariance.
What you can do is add a new property ‘myView’, and make it simply typecast the ‘view’ property. This will alleviate typecasts throughout your code. Just assign your view subclass to the view property, and everything should work fine.