Take the 2-minute tour ×

What is the difference between "+" and "-" before the function name interface declaration in an Objective-C program. Example:

- (void)continueSpeaking;

+ (NSArray *)availableVoices;

What's the difference?

share|improve this question
And just to be complete: This is not at all iPhone specific, this is Objective-C. –  Felix Kling Apr 9 '10 at 22:46
@user280556 Please accept the answer in order that the question is not lingering in the 'Unanswered' section. –  Jacob Relkin Apr 11 '10 at 21:44

1 Answer 1

up vote 13 down vote accepted

+ defines a class method

Class methods belong to the class itself, not instances of the class.

Example: [AppDelegate someMethod]

- defines an instance method

Example [[[UIApplication sharedApplication] delegate] someMethod]

One way to describe the difference is that - methods operate on objects, while + methods operate on the class itself.

Say your class was named MyClass, and you created an instance of it and stored it into a variable called myInstance:

- (void)continueSpeaking can be called like so: [myInstance continueSpeaking].

However, the method + (NSArray *)availableVoices can only be called like so: [MyClass availableVoices]

share|improve this answer
You're thinking of Java. They are called class methods in Objective-C, and there is a self in a class method — self is the class. So for example, if your class has the methods +[MyClass someMethod] and +[MyClass someOtherMethod], you could call [self someOtherMethod] from within someMethod. –  Chuck Apr 9 '10 at 22:54
Note that the standard alloc is a class method that returns an instance, while init is an instance method. –  outis Apr 9 '10 at 23:10
ok, so for others with a c# brackground: + = Static Method –  user230910 May 17 at 10:30

Your Answer


