Digraphs and Identifiers

 

Digraph Characters

The following special two-character sequences (digraphs) are equivalent to the listed single-character punctuators:

 Digraph Meaning

 <: [
 :> ]
 <% {
 %> }
 %: #
 %:%: ##

 

 

 

 

 

 

Identifiers

An 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 Names

A 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.

Keywords

The 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

Directives

Compiler 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

 DirectiveMeaning  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>
@privateDefines the scope of one or more instance variables. See “Instance Variables.”

@protectedDefines the scope of one or more instance variables 
@publicDefines the scope of one or more instance variables 
@property (list) namesDeclares properties in list for names.property (retain, nonatomic) NSSTRING *name;

@protocolCreates a Protocol object for a
specified protocol.
@protocol (Copying)]){...} if ([myObj conformsTo: (protocol)
@protocol nameBegins 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.”
@tryBegins a block to catch exceptions.See “Exception Handling.”
@catch (exception)Begins a block to process exception. 
@finallyBegins a block that gets executed
whether an exception is
thrown in the previous @try
block.
 
@throwThrows an exception. 

 
Predefined Identifiers

Table B.2 lists identifiers that have special meanings in Objective-C programs.
Table B.2 Special Predefined Identifiers


IdentifierMeaning
_cmdA 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
BOOLBoolean value, typically used with YES and NO
ClassClass object type
idGeneric object type
IMPPointer to a method returning the value of type id
nilNull object
Nil Null class object
NODefined as (BOOL) 0
NSObject Root Foundation object defined in <Foundation/NSObject.h>
Protocol Name of class for storing information about protocols
SELA 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
YESDefined as (BOOL) 1