Method declaration starting with "+"?


#1

In the “Dependent properties” paragraph the declaration of the keyPathsForValuesAffectingLastTimeString method starts with a “+”. Perhaps I missed something, but isn’t this the first time that a method is declared that way? I tried changing it in “-” but then it doesn’t work, so it does make a difference.

Can someone explain de difference between declaring with “+” and “-” to me?


#2

A method declaration that starts with a '+’ is a class-method declaration, whereas one that starts with a ‘-’ is an instance-method declaration.

For example:

// An instance method
- (void)giggle;

// A class method
+ (void)wiggle;

A class method operates on its own class object, and there is only one class object for a given class.

[Become a competent programmer: pretty-function.org]