Changes

Jump to: navigation, search

An Overview of Objective-C Object Oriented Programming

1 byte added, 19:33, 14 October 2009
Define Class Methods
The methods of a class are essentially code routines that can be called upon to perform specific tasks within the context the an instance of that class.
Methods come in two different forms, ''class methods'' and ''instance methods''. Class methods operate at the level of the class, such as creating a new instance of a class. Instance methods, on the other hand, operate only on the instance of a class (for example performing an arithmetic operation on two instance variables and returning the result). ''Class methods'' are preceded by a plus (+) sign in the declaration and instance methods are preceded by a minus (-) sign. If the method returns a result, the name of method must be preceded by the data type returned enclosed in parentheses. If a method does not return a result, then the must be declared as ''void''. If data needs to be passed through the member (referred to as ''arguments''), the member name is followed by a colon, the data type in parentheses and a name for the argument. For example, the declaration of a method to set the account number in our example might read as follows:
<tt>-(void) setAccountNumber: (long) y;</tt>

Navigation menu