构建错误 - 实例消息的接收器类型"ViewController"是前向声明

jla*_*jla 1 iphone compiler-errors ios5

我在构建时遇到2个错误,它们位于AppDelegatem文件中

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

有两个错误的行:

self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
Run Code Online (Sandbox Code Playgroud)

ERROR1:

Receiver type "ViewController" for instance messages is a forward declaration
Run Code Online (Sandbox Code Playgroud)

误差2:

Receiver "ViewController" for class messages is a forward declaration
Run Code Online (Sandbox Code Playgroud)

警报线:

self.window.rootViewController = self.viewController;
Run Code Online (Sandbox Code Playgroud)

警报:

Incompatible pointer types assigning to 'UIViewController *' from 'ViewController*'
Run Code Online (Sandbox Code Playgroud)

如果需要,你可以找到ViewControllerm的文本文件ViewControllerh AppDelegatem这里http://ninjabreakbot.com/stack/

项目适用于iOS5,我对此非常陌生.请让我知道对此类问题有用的内容.或者,如果提供了足够的解决方案!

谢谢!

He *_*ing 5

错误消息:instance messages is a forward declaration通常意味着编译器不知道类的声明,即您没有包含正确的标头.

在您的情况下#import <ViewController.h>,在AppDelegate.m的开头写入应解决此编译器问题.