Swift & Objective-C

Objective-C at-sign (@) syntax: Why does everything start with @? (Complete Guide)

When you first open Objective-C code, one thing immediately catches your eye.

4 min read
Cover image for Objective-C at-sign (@) syntax: Why does everything start with @? (Complete Guide)

When you first open Objective-C code, one thing immediately catches your eye.

It is the at-sign (@) appearing everywhere.

You write @interface, @property, and even strings as @“Hello”. At first, you might wonder, “Is this a typo?”

But there is a very clear reason for this @.

In Objective-C, @ signals to the compiler, “From here on, this is Objective-C extension syntax, not pure C.”

Today, we will take a relaxed look at why the at-sign appears identically in @interface, @property, and @“strings”.


What exactly is Objective-C @?

Let’s start with the key point.

@ is a special symbol that tells the compiler, “This is syntax specific to Objective-C.”

To understand this, you need to know how Objective-C originated.

Objective-C is not an entirely new language. It is a language that adds object-oriented features on top of C.

In other words, it includes 100% of the C language and adds features such as classes and messages.

But this creates one problem.

From the compiler’s perspective, it must distinguish the original C syntax from the newly added Objective-C syntax.

The marker that draws that boundary was @.


Why specifically the at-sign (@)?

There is an asterisk (*) and a hash (#), so why choose @?

The answer is surprisingly practical.

The @ symbol is not used anywhere in standard C syntax.

Let’s recall the characters used in C.

  • Variable and function names: letters, numbers, and underscores (_)
  • Operators: +, -, *, /, =, &, and so on
  • Preprocessor: # (for example, #include)

@ appears nowhere on this list.

That is why the creators of Objective-C adopted @. It was a safe symbol that could never conflict with existing C code.

If they had used the word interface as a keyword instead of @, all existing C code using a variable named interface would have broken.

Prefixing it with @ prevents that kind of conflict at the source.

Put simply, @ is like the handle of a separate drawer containing Objective-C-specific syntax.

@ marks the boundary between what comes from C and what Objective-C adds
@ marks the boundary between what comes from C and what Objective-C adds

Why @interface, @property, and @“strings” all use @

Now we get to the main point. Let’s see why these three seemingly different things all start with @.

The conclusion is simple: all three are features specific to Objective-C that do not exist in C.

Let’s look at them one by one.

@interface — A directive that opens a class’s skeleton, or declaration. Since C has no concept of classes, it had to be marked with @. Its counterparts, @implementation and @end, exist for the same reason.

@property — A feature that automatically creates an object’s property. This syntax also does not exist in pure C, so it gets an @.

@“strings” — This is the most interesting one. “Hello” with only quotation marks and @“Hello” are completely different things.

Let’s compare them in a table.

Category “Hello” @“Hello”
What it is C-style character array NSString object
Belongs to Original C syntax Objective-C extension
Function A simple sequence of characters Methods such as length are available

Adding just one @ before the quotation marks turns a simple chunk of text into an “object.”

That is why @ is needed. It is essentially an instruction saying, “Create this string as an NSString object, not as an ordinary C string.”

In summary:

Whether it is @interface, @property, or @“strings”, all of them use the same @ marker because they are features that do not exist in C and are specific to Objective-C.


See it at a glance in code

That may sound abstract when explained only in words, so here is a short example.

Below is a simple class declaration. Notice how @ wraps Objective-C syntax.

@interface Person : NSObject   // Start of class declaration (CSyntax not available in C)
@property NSString *name;      // Automatic property generation
@end                           // End of declaration

NSString *greeting = @"Hello"; // Before the quotation marks @ → NSString Object

As you can see, every line starting with @ is a feature newly added by Objective-C.

Conversely, the parts without @ are syntax carried over directly from C.

Just by checking whether @ is present, you can immediately see, “Ah, this is an Objective-C extension.”

Following the @ signs alone makes code much easier to read
Following the @ signs alone makes code much easier to read

Frequently asked questions (Q&A)

Q. Is @ the same as the preprocessor’s #?

No. The # in #include is a preprocessor directive handled before compilation. @, on the other hand, is an Objective-C compiler directive interpreted directly by the compiler, so they serve different roles.

Q. Are there many other kinds of @ syntax?

Yes, quite a few: @protocol, @selector, @try/@catch, and @autoreleasepool, among others. In newer syntax, you can also conveniently create @[] arrays, @{} dictionaries, and even numeric objects such as @42.

Q. Swift has @ too, right?

That’s right. Its meaning is slightly different, though. In Swift, @ is mainly used to mark attributes, such as @State and @IBOutlet. The origin is similar, but their uses should be distinguished.


The at-signs attached to each piece of code may feel unfamiliar, but once you know they mark the boundary between C and Objective-C, they start to feel reassuring.

Following the @ signs makes it immediately clear where the object-oriented syntax begins. Keep this one perspective in mind when reading Objective-C code, and it will become much easier. Happy coding!