5
I wanted to know the difference in the time of creating a method using the "+" and "-"?
And also when to use and why to use, I usually only use the "-", but I don’t know how to use the method with "+".
Thank you.
5
I wanted to know the difference in the time of creating a method using the "+" and "-"?
And also when to use and why to use, I usually only use the "-", but I don’t know how to use the method with "+".
Thank you.
9
So, the methods with prefix -
are instance methods, i.e., you can only call these methods through an instance of the class:
NSString *instanciaString = [[NSString alloc] init];
[instanciaString length];
And the 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"];
Browser other questions tagged ios objective-c
You are not signed in. Login or sign up in order to post.