我正在创建一款游戏,让玩家将飞机滑入正确的车道。但是,我最近在我的游戏屏幕上添加了一架飞机。但是,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/