The names of files that contain Objective-C source code have the .m extension. Files that declare class and category interfaces or that declare protocols have the .h extension typical of header files.
Class, category, and protocol names generally begin with an uppercase letter; the names of methods and instance variables typically begin with a lowercase letter. The names of variables that hold instances usually also begin with lowercase letters.
In Objective-C, identical names that serve different purposes don’t clash. Within a class, names can be freely assigned:
A class can declare methods with the same names as methods in other classes.
A class can declare instance variables with the same names as variables in other classes.
An instance method can have the same name as a class method.
A method can have the same name as an instance variable.
Method names beginning with “_”, a single underscore character, are reserved for use by Apple.
Likewise, protocols and categories of the same class have protected name spaces:
A protocol can have the same name as a class, a category, or anything else.
A category of one class can have the same name as a category of another class.
However, class names are in the same name space as global variables and defined types. A program can’t have a global variable with the same name as a class.
Last updated: 2008-02-05