Example of method definition:
-(Void) insertobject :( ID) anobject atindex :( nsinteger) Index
Explanations:
1. Method Modifier
-This method is an entity method. It must be a class instance and can be called only through an instance.
+ Indicates that this method is a static method of the class and can be called directly without generating a class instance.
2. Parameter type
ID and nsinteger are the anobject and index parameters respectively.
3. Method Signature
In this example, insertobject and atindex constitute the signature keyword of this method.
Here is an example:
-(Void) setto: (INT) n over: (INT) d
{
Numerator = N;
Denominator = D;
}
[Afraction setto: 100 over: 200]; // call
Note: The method parameter name of objective-C is somewhat odd. The first parameter does not have a parameter name. If it is hard to say yes, it is the method name,
In general, when we see the colon, the parameter name is prior to the colon.
For example, a method without a parameter name is defined and called:
-(INT) set: (INT) N: (INT) D; [afraction set: 1: 3]; // call