Header file names should match the class name, protocol name, or category name defined in the file. Header files should contain a single class definition. If a header contians a protocols or categories in addition to the class name, name the header after the class name.
Header file names should describe their contents. By using the same name, the header file and the class, protocol, or category declaration are inherently linked. Limiting headers to a single class helps keep APIs clear, concise, and easily searchable.
// Object.h
// bad: header name doesn't match class name
// XYZObject.h
// good: header name matches class name
@interface XYZObject : NSObject
@end
// bad: multiple classes defined in the same file
@interface XYZObject : NSObject
@end
@interface XYZRelatedObject : NSObject
@end
// XYZViewProtocols.h
// bad: doesn't match the protocol name
// XYZViewHidingProtocols.h
// bad: doesn't match the protocol name
// XYZViewHiding.h
// good: matches the protocol name
@protocol XYZViewHiding;
// XYZObjectAndProtocols.h
// bad: name doesn't match the class name
// XYZObjectDelegate.h
// bad: name doesn't match the class name
// XYZObject.h
// good: name matches the class name
@protocol XYZObjectDelegate
// ...
@end
@interface XYZObject : NSObject
@property (nonatomic, weak) id<XYZObjectDelegate>delegate;
@end
See category naming for examples of naming headers containing categories and other extensions.