A category is declared in much the same way as a class. The interface file that declares the class must be imported:
#import "ClassName.h" |
@interface ClassName ( CategoryName ) < protocol list > |
method declarations |
@end |
The protocol list and method declarations are optional. If any protocols are listed, the header files where they’re declared must also be imported.
Like a class definition, a file containing a category definition imports its own interface:
#import "CategoryName.h" |
@implementation ClassName ( CategoryName ) |
method definitions |
@end |
Last updated: 2008-02-05