Iphone 构建错误-接收器类型“;“视图控制器”;例如,消息是一个转发声明

Iphone 构建错误-接收器类型“;“视图控制器”;例如,消息是一个转发声明,iphone,ios5,compiler-errors,Iphone,Ios5,Compiler Errors,我在构建时遇到2个错误,它们位于AppDelegatem文件中 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point fo

我在构建时遇到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;
}
有两个错误的行:

self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
错误1:

Receiver type "ViewController" for instance messages is a forward declaration
Receiver "ViewController" for class messages is a forward declaration
Incompatible pointer types assigning to 'UIViewController *' from 'ViewController*'
错误2:

Receiver type "ViewController" for instance messages is a forward declaration
Receiver "ViewController" for class messages is a forward declaration
Incompatible pointer types assigning to 'UIViewController *' from 'ViewController*'
带有警报的行:

self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
警报:

Receiver type "ViewController" for instance messages is a forward declaration
Receiver "ViewController" for class messages is a forward declaration
Incompatible pointer types assigning to 'UIViewController *' from 'ViewController*'
如果需要,您可以找到 视图控制器项 视图控制器 AppDelegatem 这里

这个项目是针对iOS5的,我对这个很陌生。请让我知道这类问题的有用之处。或者,如果已经提供了足够的解决方案,请提供您的解决方案


谢谢

错误消息:
实例消息是转发声明
通常意味着编译器不知道类的声明,即没有包含正确的头


在您的情况下,在AppDelegate.m的开头写入
#import
,应该解决这个编译器问题。

错误消息:
实例消息是一个转发声明
通常意味着您编译器不知道类的声明,即您没有包含正确的头


在您的情况下,在AppDelegate.m的开头编写
#import
,应该解决这个编译器问题。

检查
initWithNibName
。nib文件名是
ViewController
还是其他名称

编写
#导入“ViewController.h”
@property(强,非原子)ViewController*ViewController

编写
@综合视图控制器

.h文件::

#import <UIKit/UIKit.h>
#import "ViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;

@end

选中
initWithNibName
。nib文件名是
ViewController
还是其他名称

编写
#导入“ViewController.h”
@property(强,非原子)ViewController*ViewController

编写
@综合视图控制器

.h文件::

#import <UIKit/UIKit.h>
#import "ViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;

@end

我的AppDelegate.m文件包含一行#import“ViewController.h”有一个指向我的文件的链接,您可以在我的帖子中查看,非常感谢您的帮助。这个答案确实帮助我解决了一个与类别相关的问题。谢谢我的AppDelegate.m文件包含一行#import“ViewController.h”有一个指向我的文件的链接,您可以在我的帖子中查看,非常感谢您的帮助。这个答案确实帮助我解决了一个与类别相关的问题。谢谢My.xib称为ViewController添加这些行不会解决任何错误#import“ViewController.h”不在我的AppDelegate.h文件中,但是您提到的下一行是。还添加了@synthesis viewController;在AppDelegate.m中,文件给出了错误(非法的接口限定符),谢谢您的帮助。nib文件名看起来像X代码的项目导航器中的ViewController.xib。@PrasadG我得到了这个错误。。我必须做的。。请引导我,我在另一个视图中得到这个,我想称之为method@Babul:我能为您效劳吗?。向我简要解释。@PrasadG我在我的应用程序中是这样做的#ifdef#uu cplusplus#import#import“OpenCVClientViewController.h”#end如果我需要调用“OpenCVClientViewController”中的方法,它会给我上面发布的错误my.xib称为ViewController添加这些行不会解决任何错误#import“ViewController.h”不在我的AppDelegate.h文件中,但是您提到的下一行是。还添加了@synthesis viewController;在AppDelegate.m中,文件给出了错误(非法的接口限定符),谢谢您的帮助。nib文件名看起来像X代码的项目导航器中的ViewController.xib。@PrasadG我得到了这个错误。。我必须做的。。请引导我,我在另一个视图中得到这个,我想称之为method@Babul:我能为您效劳吗?。向我简要解释。@PrasadG我在我的应用程序#ifdef uu cplusplus#import#import“OpenCVClientViewController.h”#end中这样做了,如果我需要调用“OpenCVClientViewController”中的方法,它会给出上面发布的错误