Yos Riady software craftsman 🌱

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

Yos is a software craftsman based in Singapore.

📬 Subscribe to my newsletter

Get notified of my latest articles by providing your email below.


Going Serverless book

Interested to find out more about serverless? Going Serverless 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 →