I wanted to know what the difference is when I create a method using the "+" and "-"?
And also when to use and why to use, I usually only use the "-", but I do not know how to use the method with "+".
Thank you.
I wanted to know what the difference is when I create a method using the "+" and "-"?
And also when to use and why to use, I usually only use the "-", but I do not know how to use the method with "+".
Thank you.
Thus, methods with -
are instantiation methods, that is, you can only call these methods through an instance of the class:
NSString *instanciaString = [[NSString alloc] init];
[instanciaString length];
And methods with the +
prefix are class methods. These methods do not need an instance to be called, you can call directly from the class, for example:
[NSString stringWithString:@"Hello World"];