I have a subclass of UIViewController that is responsible for a single UIWebView.
Since this is a simple case, I override -(void)loadView
, instantiate the UIWebView and assigning it the controller's view
property:
- (void)loadView
{
UIWebView *wv = [[[UIWebView alloc] initWithFrame:self.frame] autorelease];
// other configuration here...
self.view = wv;
}
This is fine until I call a method of UIWebView's. For example...
[self.view loadHTMLString:HTMLString baseURL:baseURL];
...leads to a compiler warning...
warning: 'UIView' may not respond to '-loadHTMLString:baseURL:'
...since the view
property is declared as UIView
.
NOW the warning is easily solved with a cast...
[(UIWebView *)self.view loadHTMLString:HTMLString baseURL:baseURL];
...but what I'd like to do is provide the correct type hint in the interface. I tried overriding the view
property in MyViewController.h
but this upsets the compiler too:
warning: property 'view' type does not match super class 'UIViewController' property type
Is there any way of telling the compiler (and my fellows) that this is what I'm doing, and that I know that this is what I'm doing and that it's all okay? (If not I guess I'll stick with the cast.)
TIA
EDIT: I tried redeclaring the view property as per marcus.ramsden's answer: this eliminated the warning (and the need for the cast) but stopped the view appearing at all! I'm not sure why this should be as the controller will still return a UIView (subclass) when asked for it...