Shi Zhang
Shi Zhang

Reputation: 163

Use of undeclared identifier [objective-c]

i have an Object_Info.h (contains the interface declaration) and Object_Info.m (contains some not all method implementations) files in the same directory as my main.m.

in main.m

#import <Foundation/Foundation.h>
#import "Object_Info.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        error thrown here -> use of undeclared identifier 'tempObjInfo'
        (Object_Info*) tempObjInfo = [[Object_Info alloc] init];
    }
    return 0;
}

any ideas as to why the error is there? user of undeclared identifier 'tempObjInfo'

I've tried (Object_Info*) tempObjInfo = [Object_Info new] as well with no success.

Thanks!

Upvotes: 0

Views: 1159

Answers (1)

Michael Reneer
Michael Reneer

Reputation: 2601

You didn't declare the identifier. You should declare it like...

Object_Info *tempObjInfo = [[Object_Info alloc] init];

... or if the tempObjInfo symbol is declared somewhere globally you will need to include the header where it is being declared.

Upvotes: 1

Related Questions