Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the @ symbol mean for Objective-C?

I know the following uses of @ (at symbol):

@"myString" - is used to indicate an objective-c NSString, rather than a standard C string

@keyword - used to identify some objective c keywords such as @implementation, @synthesize, @class and @interface

What does @KEYNAME mean in the context below?

[SFHFKeychainUtils storeUsername:@KEYNAME andPassword:[NSString stringWithUTF8String:b64data] forServiceName:@"default" updateExisting:YES error:&ter_ror];

Does @ have any other possible meanings?

like image 732
Casebash Avatar asked Feb 10 '11 02:02

Casebash


1 Answers

It means nothing at all in the context of your code snippet. That will fail with a syntax error.

The reason @ is used in Obj-C keywords and in constant strings is because @ is not a valid character to use as part of a token in C, and Obj-C is a strict superset of C. This means that all valid C code is valid Obj-C code, so Obj-C can't take any keywords that could have possibly shown up in valid C. Since @ isn't valid in tokens, that means Obj-C could simply use it to start all of its keywords and not worry about collisions.

As for other possible meanings, there are a few keywords you omitted, such as @protocol, @dynamic, @private, @protected, @public, @selector, and @encode.

like image 131
Lily Ballard Avatar answered Sep 28 '22 14:09

Lily Ballard