The typedef Statement
Objective-C provides a capability that enables the programmer to assign an alternative name to a data type. This is done with a statement known as typedef. The following statement defines the name Counter to be equivalent to the Objective-C data type int:
typedef int Counter;
You can subsequently declare variables to be of type Counter, as in the following statement:
Counter j, n;
The Objective-C compiler treats the declaration of the variables j and n, shown previously, as normal integer variables. The main advantage of the use of the typedef in this case is in the added readability it lends to the definition of the variables. The definition of j and n makes clear the intended purpose of these variables in the program. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access