I have a ViewController class (maybe I shouldn't have named that class that way ?)
Why do I have a warning
Incompatible pointer type assigning to 'ViewController' from 'UIViewController' in AppDelegate
Update:
at this line
self.viewController = [[[myPlugin alloc] getPluginViewController] autorelease];
in AppDelegate.h I have
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@end
in myPlugin I have
-(ViewController*) getPluginViewController {
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
return self.viewController;
In ViewController I have
@interface ViewController : UIViewController {
The viewController property in your app delegate probably has type UIViewController*
and you are trying to assign an object of type ViewController*
to it. Probably your ViewController class needs to inherit from UIViewController.
There are many other problems with your code:
self.viewController = [[[myPlugin alloc] getPluginViewController] autorelease];
Ignoring the assignment, the first message sent to an object straight after it has been allocated should be an init message by convention. 99.99% of programmers will automatically assume this is a horrendous bug in your code whether or not it is a horrendous bug. You should stick to the conventions.
Also, if getPluginViewController
abides by the memory management rules, you do not own the object it returns, so you must not autorelease it.
-(ViewController*) getPluginViewController {
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
return self.viewController;
}
In itself, this is kind of OK. In Objective-C, by convention, a method beginning with "get" is for methods that return values in pointer parameters. However, putting it together with where you call it there are several problems: