Learn Objective-C: Reserved Keywords
Objective-C reserves certain words, so that you can’t, or shouldn’t, use them in your own code. At best, you’ll get a compiler warning or error; at worst, you’ll get a nasty bug that you won’t discover until millions of people are already using your app. Here is a list of reserved keywords, to help you avoid that pitfall.
| Words You Can’t Use | Words You Shouldn’t Use |
|---|---|
| auto | BOOL |
| break | Class |
| case | bycopy |
| char | byref |
| const | id |
| continue | IMP |
| default | in |
| do | inout |
| double | nil |
| else | NO |
| enum | NULL |
| extern | oneway |
| float | out |
| for | Protocol |
| goto | SEL |
| if | self |
| inline | super |
| int | YES |
| long | @interface |
| register | @end |
| restrict | @implementation |
| return | @protocol |
| short | @class |
| signed | @public |
| sizeof | @protected |
| static | @private |
| struct | @property |
| switch | @try |
| typedef | @throw |
| union | @catch() |
| unsigned | @finally |
| void | @synthesize |
| volatile | @dynamic |
| while | @selector |
| _Bool | atomic |
| _Complex | nonatomic |
| _Imaginary | retain |
This post is part of the Learn Objective-C in 24 Days course.