Warning when presenting a UIViewController
I am creating another instance my main view controller and pre开发者_开发知识库senting it.
MainViewController *sm = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil];
[self presentModalViewController:sm animated:NO];
[sm release];
This gives the following errors
warning: receiver 'MainViewController' is a forward class and corresponding @interface may not exist
warning: incompatible Objective-C types 'struct MainViewController *', expected 'struct UIViewController *' when passing argument 1 of 'presentModalViewController:animated:' from distinct Objective-C type
What am I doing wrong? How can I present the current version of MainViewController that exists?
You have a forward declaration in your header file
@class MainViewController;
but you do not import the header file in your implementation file.
Add
#import "MainViewController.h"
to the top of the .m file.
import "MainViewController.h"
in your .m file.
精彩评论