December 2012
Beginner
552 pages
12h 58m
English
A definition for a name can include more than a simple constant value. It can include an expression and, as you will see shortly, just about anything else!
The following defines the name TWO_PI as the product of 2.0 and 3.141592654:
#define TWO_PI 2.0 * 3.141592654
You can subsequently use this defined name anywhere in a program where the expression 2.0 * 3.141592654 would be valid. So, you could replace the return statement of the circumference method from the previous example with the following statement:
return TWO_PI * radius;
Whenever a defined name is encountered in an Objective-C program, everything that appears to the right of the defined name in the #define statement is literally substituted for the ...
Read now
Unlock full access