Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C – Expected identifier error

I'm getting an expected identifier error when I try to compile my code.

careerURL is setup like this in .h file:

@property (nonatomic, copy) NSString *careerURL;

And synthesized like this in .m file:

@synthesize careerURL;

I really do not understand what is the issue here. The exact code works in another viewcontroller.

enter image description here

like image 249
Peter Warbo Avatar asked Oct 21 '11 08:10

Peter Warbo


2 Answers

You should either use dot . syntax,

NSString *wtf = self.careerURL;

Or Objective-C message syntax,

NSString *wtf = [self careerURL];

Not both at the same time.

like image 195
EmptyStack Avatar answered Sep 21 '22 18:09

EmptyStack


You should write:

 NSString *wtf = self.careerURL;

When you are writing [object method] it is expected that you want to call method method from object object. If you want just access some value (that is defined as @property) you can type:

[self nameOfValue];

or

self.nameOfValue;
like image 30
Nekto Avatar answered Sep 19 '22 18:09

Nekto