How to write a method/message with multiple parameters?

Devoted picture Devoted · Jul 1, 2009 · Viewed 40.1k times · Source

How do you write a method/message with multiple parameters?

EDIT: Like multiple parameters for a single method/message, I mean.

Answer

Jeff Hellman picture Jeff Hellman · Jul 1, 2009

You can write the declaration as such:

- (void) drawRoundedRect:(NSRect)aRect inView:(NSView *)aView withColor:(NSColor *)color fill:(BOOL)fill

The subsequent call (with 4 parameters) could look like:

[self drawRoundedRect:rect inView:self withColor:[NSColor greenColor] fill:YES];

where rect is a previously defined NSRect, self is the NSView the method is called from, an NSColor object obtained from a nested method call, and the constant boolean value YES.