iphone - 语义问题 : Use of undeclared identifier

标签 iphone objective-c ios xcode xcode4

我正在创建一款游戏,让玩家将飞机滑入正确的车道。但是,我最近在我的游戏屏幕上添加了一架飞机。但是,Xcode 说我正在使用和未声明的标识符。我对此很陌生,所以请帮忙。
这是我控制游戏的头文件。 GamePlayViewController.h

#import <UIKit/UIKit.h>

@interface GamePlayViewController : UIViewController

@end

这是我的 GamePlayViewController.m 这是出现错误的地方。

    #import "GamePlayViewController.h"

#import "Airplane.h"

@interface GamePlayViewController ()

@end

@implementation GamePlayViewController

-(void) viewWillAppear:(BOOL)animated {
    //Add a vehicle
    Airplane* v = [[Airplane alloc]
                   initWithFrame:CGRectMake(221, 228, 0, 0)
                   [self.view addSubview:v];
}

@end

错误出在 Airplane* v [[Airplane alloc]。它说 Use of undeclared identifier "Airplane"and also "v"

我在 Google 和 Stackoverflow 上搜索了所有答案,但没有一个场景符合我的情况。

顺便说一句,提前感谢任何回答者。

最佳答案

你从这一行的哪里声明图像?

image = [loadedImage retain];

我猜你不会。


添加这个:

 @property (nonatomic, retain) UIImage *image;

...到你的 .h,这个到你的 .m:

@synthesize image;

关于iphone - 语义问题 : Use of undeclared identifier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11370258/

相关文章:

ios - 如何切换音频输出以通过扬声器播放?

iphone - 数组元素的优雅计算

objective-c - Objective C 2.0 是否发生了如此大的变化以至于旧代码将不再运行? Apple 目前只有 Obj C 吗?

IOS UITableViewCells 都混杂在第一个单元格中,尽管只有 Iphone5S 设备,64 位模拟器

ios - Swift ios 使用 unix 时间戳

ios - 从 iPhone 本地存储读取文件

iphone - 有没有Apple Direction API?

iphone - 在 ARC 上使用 SCRFTPRequest 进行 iOS FTP 上传

iphone - 在 TabBar 中更改选项卡时,UIButtons 文本显得更暗

html - 从 HTML 链接在 iPad 上打开 iBook 文件