When a method begins with a +
, it signifies that the method is a class method. This means that instead of calling it like:
// Calling an instance method.
[self doSomething];
you will call it like:
// Calling a class method.
[ClassName doSomething];
You don't need an instance of an object to call a class method. You might think this means that the code will run faster because you don't need to hold on to an object, but as far as I know, the runtime will actually create an object on the fly to execute your method, resulting in dramatic unresponsiveness if you frequently (thousands of times) call a class method. On the other hand, methods that start with a -
are instance methods. In order to call them, you first need to create an instance of the object. For example:
// Create the object.
SomeObject *tSomeObject = [[SomeObject alloc] init];
// Calling the method.
[tSomeObject doSomething];
Calling a method with multiple arguments works the same way as calling a single argument method. Here's how it works:
[ClassName rangeFinder:date1 isBetweenDate:date2 andDate:date3];
I would consider changing the method signature from rangeFinder:isBetweenDate:andDate:
to something more like date:isBetweenDate:andDate:
. You may also want to consider the option of date3
being less than date2
. Currently your implementation would return NO
but it seems like you would want it to return YES
.