The following conventions are used in method declarations:
Argument and return types are declared using the C syntax for type casting.
Arguments are declared after colons (:), for example:
- (void)setWidth:(int)newWidth height:(int)newHeight |
Typically, a label describing the argument precedes the colon—the following example is valid but is considered bad style:
- (void)setWidthAndHeight:(int)newWidth :(int)newHeight |
Both labels and colons are considered part of the method name.
The default return and argument type for methods is id, not int as it is for functions. (However, the modifier unsigned when used without a following type always means unsigned int.)
Last updated: 2008-02-05