This might look weird to you but yes, it is possible to declare methods in iOS which do have names. We can declare a method in objective-c which can have only parameters and no name as such.
Let us get to the point and take an example:

Consider the following method:



- (NSString *):name {  return @"Some Test String";
}

The method signature - (NSString *):name breaks down to the following:

  • - It is an instance method (versus a class method with a +).
  • (NSString *) It returns a string.
  • : If you were to speak the name of this method, it would simply be called "colon". : tells the compiler that your method accepts one parameter as well.
  • name There is a parameter called name.
Note: When you don't specify a type, the compiler assumes you meant id, so this method actually fleshes out to be - (NSString *):(id)hello
A valid call to this method would be: [self :@"hello"].
You can do really weird things because : is a valid name for a method, and the compiler assumes id.

You could, if you really wanted to, have a method called - (id):::. The compiler would assume you meant - (id):(id):(id):(id), a method that returns an object of type id and takes three parameters of type id.

You'd call it like so: [self :@"hello" :anObject :myObject];
Note: Usually, if you see a ':' with no type it will be a case like - (float)addThreeValues : : : This method returns float and takes 3 parameters. This would be an appropriate definition because the three values don't matter what order they are provided because we are just adding them.