Devoted Devoted - 1 year ago 82
Objective-C Question

How to write a method/message with multiple parameters?

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

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download