The -
identifies the method as an instance method, as opposed to the +
, which identifies the method as a class method.
The return data type is the part inside the parenthesis. You can't return an object by value, so you must return a pointer to an object, hence the *
inside the parenthesis. You are returning a pointer
to someClass
.
The beginning of the method name follows the parenthesis.
You would call this method someName
, and it returns a pointer to an object of someClass
, and it is an instance method.
If you were returning a primitive data type, the *
would be unneeded because you can return primitive data types. However, you could still return a pointer to a primitive data type, in which case you'd want the *
.
For example:
-(int)someName; //returns an integer
-(int *)someOtherName; //returns a pointer to an integer