DIRECTIVES

If you observe the content of the SomeClass.h file, you will notice that at the top of the file is an #import statement:

#import <Foundation/Foundation.h>

@interface SomeClass : NSObject {

}

@end

The #import statement is known as a preprocessor directive. In C and C++, you use the #include preprocessor directive to include a file's content with the current source. In Objective-C, you use the #import statement to do the same, except that the compiler ensures that the file is included at most only once. To import a header file from one of the frameworks, you specify the header filename using angle brackets (<>) in the #import statement. To import a header file from within your project, you use the “ and ” characters, as in the case of the SomeClass.m file:

#import “SomeClass.h”

@implementation SomeClass

@end

Get Beginning iOS 5 Application Development 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.