Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS iVar named "Size" syntax error?

Take this code :

@interface SomeClass:NSObject
{
@private
  NSString* Size;
}

@property NSString* Size;

@end

--------------------------

@implementation SomeClass
@synthesize Size;

- (void) something
{
  Size = @"syntax error : Expected identifier or '(' ";
  self.Size = @"works ok";
}

@end

Why is this a syntax error? Is "Size" a reserved word or already defined in NSSObject ? I'm getting the error on two separate projects...

like image 214
Lescai Ionel Avatar asked Nov 22 '25 16:11

Lescai Ionel


2 Answers

Size is a type:

typedef long                            Size;

Dont use it, and you should follow the Objective-C conventions, which are to name the properties with lowerCase.

like image 52
Angel G. Olloqui Avatar answered Nov 25 '25 05:11

Angel G. Olloqui


Did you option-Click or cmd+Click on Size (not self.Size)? X Code should tell you that it is declared in MacTypes.h as typedef long Size;

like image 34
Killian Avatar answered Nov 25 '25 04:11

Killian