The #import Statement

When you have programmed in Objective-C for a while, you will find yourself developing your own set of macros, which you will want to use in each of your programs. But instead of having to type these macros into each new program you write, the preprocessor enables you to collect all your definitions into a separate file and then include them in your program, using the #import statement. These files—similar to the ones you’ve previously encountered but haven’t written yourself—normally end with the characters .h and are referred to as header or include files.

Suppose that you are writing a series of programs for performing various metric conversions. You might want to set up some #define statements for the various constants ...

Get Programming in Objective-C, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.