Your specific syntax will work as a message declaration, but the result will not be what you expect.
-(NSInteger) totalSeconds:hours:(NSInteger)h
minutes:(NSInteger)m seconds:(NSInteger)s;
The way the compiler will see this is the following:
-(NSInteger) totalSeconds:(id)hours:
(NSInteger)h
minutes:(NSInteger)m
seconds:(NSInteger)s
hours
becomes the parameter name for the id
parameter type, not the identifier for the h
parameter. In order to call it, the call winds up looking very funky:
[self totalSeconds:nil :12 minutes:50 seconds:42];
Notice that you now have to pass an object as the first parameter (I've chosen nil
), and the word hours
is no longer in the call.
I would not name the message in this way. As Rudedog has said here, the idea is that you should be able to read the call like an English sentence. Go with a name similar to his or Nick Veys'.
From your comment:
This is part of my question. Is that
the standard way? To adapt the name of
the method itself to the first
parameter rather than labeling the
first parameters as you do the others.
Yes, the standard is to name the message such that the first parameter "name" is part of the message itself. Understand that the selector includes all of this information in it. The selector for the message, as named above, is:
totalSeconds::minutes:seconds
As named better, the selector should read something like:
totalSecondsFromHours:minutes:seconds