views:

67

answers:

2

For example, NSString documentation has

– initWithFormat:
– initWithFormat:arguments:
– initWithFormat:locale:
– initWithFormat:locale:arguments:
– initWithData:encoding:
+ stringWithFormat:
+ localizedStringWithFormat:
+ stringWithCharacters:length:
+ stringWithString:
+ stringWithCString:encoding:
+ stringWithUTF8String:

So what does it mean when a method name has a + at its left?

+7  A: 

+ is for class methods (aka static methods in languages like C# and Java) - methods which relate to the type rather than a specific instance of the type.

- is for instance methods; methods which are called on a particular instance.

So for example, we have

- length
+ availableStringEncodings

because length refers to the length of a specific string, whereas availableStringEncodings just returns a list of the encodings available on the system.

This is just part of Objective-C - I suggest you find a good Objective-C book or tutorial.

Jon Skeet
A more complete answer! But the first answer was submitted first. I've never been so torn in my life :S
bobobobo
Actually I think my answer was just about submitted first, but it really doesn't matter :)
Jon Skeet
+2  A: 

method with + is a static method. so you will send message to class, not to it's instance.

Morion