What is the difference between methods that are declared with - and methods that are declared with +
e.g
- (void)methodname
+ (void)methodname
See Question&Answers more detail:osWhat is the difference between methods that are declared with - and methods that are declared with +
e.g
- (void)methodname
+ (void)methodname
See Question&Answers more detail:osMethods prefixed with -
are instance methods. This means they can only be invoked on an instance of a class, eg:
[myStringInstance length];
Methods prefixed with +
are class methods. This means they can be called on Classes, without needing an instance, eg:
[NSString stringWithString:@"Hello World"];