Yos Riady optimize for learning

Objective-C @ Compiler Directives

In iOS Development, @ is a shorthand/syntactic sugar unique to Objective-C that does different things depending on the context. For example, for NSArray literals, @[] returns an NSArray object initialized with the comma-delimited list of objects as its contents.

The below two lines are equivalent:

@[@"A", @NO, @2.718]
[NSArray arrayWithObjects:@"A", @NO, @2.718, nil]

The @ sign is also used for @interface, @implementation, properties through @property and @synthesize, and instance variable visibility such as @public and @protected.

Additional information:

Author

You should follow him on Twitter.

📬 Get updates straight to your inbox!

Subscribe to my newsletter to make sure you don't miss anything.




Here's something you might be interested in...

Going Serverless book

Have you heard about the Serverless programming model? The Going Serverless book teaches you how to build scalable applications with the Serverless framework and AWS Lambda. You'll learn how to design, develop, test, deploy, and secure Serverless applications from planning to production.

Learn more →