Monday, January 12, 2009

Multiple arguments in a method

Syntax for multiple argument passing in a Objective-C method is quite different from that of C/Java. If a method have multiple arguments, the selector (method name) will have multiple parts. For example

[someArray insertObject: element];

have one argument. Whereas following with one selector will have two arguments.

[someArray insertObject: element atIndex:1];

Remember that inserObject:atIndex: is one selector, which will trigger one method with two arguments.