bobobobo
bobobobo

Reputation: 67234

What does the + mean on Mac Dev Center?

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?

Upvotes: 0

Views: 135

Answers (2)

Morion
Morion

Reputation: 10860

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

Upvotes: 2

Jon Skeet
Jon Skeet

Reputation: 1500525

+ 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.

Upvotes: 7

Related Questions