开发者

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

开发者_JAVA百科

@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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜