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?
+
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.
method with + is a static method. so you will send message to class, not to it's instance.
精彩评论