PoisonNinja
PoisonNinja

Reputation: 227

Semantic Issue: Use of undeclared identifier

I am creating a game that has players swiping the planes into the correct lanes. However, I recently added a airplane to my game screen. However, Xcode says that I am using and undeclared identifier. I am new to this so please help.
Here is my header file controlling the game. GamePlayViewController.h

#import <UIKit/UIKit.h>

@interface GamePlayViewController : UIViewController

@end

Here is my GamePlayViewController.m This is where the error appears.

    #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

The error is at the Airplane* v [[Airplane alloc]. It says Use of undeclared identifier "Airplane" and also "v"

I have searched all over Google and Stackoverflow for the answer, but none of the scenarios matched my situation.

By the way, thanks in advance to whoever answers.

Upvotes: 2

Views: 5678

Answers (1)

JoeCortopassi
JoeCortopassi

Reputation: 5093

Where do you declare image from this line?

image = [loadedImage retain];

my guess is you don't.


Add this:

 @property (nonatomic, retain) UIImage *image;

...to your .h, and this to your .m:

@synthesize image;

Upvotes: 1

Related Questions