【问题标题】:Semantic Issue: Use of undeclared identifier语义问题:使用未声明的标识符
【发布时间】:2012-07-06 22:04:22
【问题描述】:

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

错误出现在飞机* v [[Airplane alloc]。它说使用未声明的标识符“飞机”和“v”

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

顺便说一句,提前感谢回答的人。

【问题讨论】:

  • 请发布确切的错误信息。
  • Airplane* v = [[Airplane alloc]更改为CAAAirplane* v = [[CAAAirplane alloc]

标签: iphone objective-c ios xcode xcode4


【解决方案1】:

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

image = [loadedImage retain];

我猜你不知道。


添加这个:

 @property (nonatomic, retain) UIImage *image;

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

@synthesize image;

【讨论】:

  • 应该发布一个全新的问题。您的新编辑对其进行了极大的改变,并且会让未来的读者感到困惑
猜你喜欢
  • 1970-01-01
  • 2012-05-28
  • 1970-01-01
  • 2015-09-21
  • 1970-01-01
  • 1970-01-01
  • 2012-09-16
  • 2012-09-16
  • 2021-05-04
相关资源
最近更新 更多