开发者

Warning when presenting a UIViewController

开发者 https://www.devze.com 2023-02-05 14:32 出处:网络
I am creating another instance my main view controller and pre开发者_开发知识库senting it. MainViewController *sm = [[MainViewController alloc]initWithNibName:@\"MainViewController\" bundle:nil];

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号