Digraph CharactersThe following special two-character sequences (digraphs) are equivalent to the listed single-character punctuators: | Digraph | Meaning |
| | <: | [ | | :> | ] | | <% | { | | %> | } | | %: | # | | %:%: | ## |
IdentifiersAn identifier in Objective-C consists of a sequence of letters (upper- or lowercase), universal character names (1.2.1), digits, or underscore characters.The first character of an identifier must be a letter, an underscore, or a universal character name.The first 31 characters of an identifier are guaranteed to be significant in an external name, and the first 63 characters are guaranteed to be significant for an internal identifier or macro name. Universal Character NamesA universal character name is formed by the characters \u followed by four hexadecimal numbers or the characters \U followed by eight hexadecimal numbers. If the first character of an identifier is specified by a universal character, its value cannot be that of a digit character. Universal characters, when used in identifier names, can also not specify a character whose value is less than A016 (other than 2416, 4016, or 6016) or a character in the range D80016 through DFFF16, inclusive. Universal character names can be used in identifier names, character constants, and character strings. KeywordsThe identifiers listed here are keywords that have special meanings to the Objective-C compiler: _Bool _Complex _Imaginary auto break bycopy byref case char const continue default do double else enum extern float for goto if in inline inout int long oneway out register restrict return self short signed sizeof static struct super switch typedef union unsigned void volatile while DirectivesCompiler directives begin with an @ sign and are used specifically for working with classes and objects, as summarized in Table B.1. Table B.1 Compiler Directives | Directive | Meaning | Example |
| | @”chars” | Defines a constant NSSTRING character string object (Adjacent strings are concatenated.) | NSString *url = @”http://www.classroomm.com”; | @class c1, c2,... | Declares c1, c2, ... as classes. | @class Point, Rectangle; | | @defs (class) | Returns a list of the structure variables for class. | struct Fract { @defs(Fraction); } *fractPtr; fractPtr = (struct Fract *) [[Fraction alloc] init]; | | @dynamic names | Accessor methods for names may be provided dynamically | @dynamic drawRect; | @encode (type)
| String encoding for type. | @encode (int *) | | @end | Ends an interface section, an implementation section, or a protocol section. | @end | | @implementation | Begins an implementation section. | @implementation Fraction | @interface
| Begins an interface section.
| @interface Fraction: NSObject <Copying>
| | @private | Defines the scope of one or more instance variables. | See “Instance Variables.”
| | @protected | Defines the scope of one or more instance variables | | | @public | Defines the scope of one or more instance variables | | | @property (list) names | Declares properties in list for names. | property (retain, nonatomic) NSSTRING *name; | | @protocol | Creates a Protocol object for a specified protocol. | @protocol (Copying)]){...} if ([myObj conformsTo: (protocol) | | @protocol name | Begins a protocol definition for name. | @protocol Copying | @selector (method) | SEL object for specified method. | if ([myObj respondsTo: @selector (allocF)]) {...} | @synchronized (object) | Begins a block to be executed by a single thread. Object is known as the mutual exclusion (mutex) semaphore. | | @synthesize names | Generates accessor methods for names if not provided. | @synthesize name, email; See also “Instance Variables.” | | @try | Begins a block to catch exceptions. | See “Exception Handling.” | | @catch (exception) | Begins a block to process exception. | | | @finally | Begins a block that gets executed whether an exception is thrown in the previous @try block. | | | @throw | Throws an exception. | |
|
Predefined IdentifiersTable B.2 lists identifiers that have special meanings in Objective-C programs. Table B.2 Special Predefined Identifiers
| | Identifier | Meaning | | _cmd | A local variable automatically defined in a method that contains the selector for the method
| | __func__ | A local character string variable automatically defined in a function or method containing the name of the function or method | | BOOL | Boolean value, typically used with YES and NO | | Class | Class object type | | id | Generic object type | | IMP | Pointer to a method returning the value of type id | | nil | Null object | | Nil | Null class object | | NO | Defined as (BOOL) 0 | | NSObject | Root Foundation object defined in <Foundation/NSObject.h> | | Protocol | Name of class for storing information about protocols | | SEL | A compiled selector | | self | A local variable automatically defined in a method that references the receiver of the message | | super | The parent of the receiver of the message | | YES | Defined as (BOOL) 1 |
|
|