How to write a method/message with multiple parameters?

前端 未结 3 793
夕颜
夕颜 2020-12-31 04:57

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

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

3条回答
  •  死守一世寂寞
    2020-12-31 05:40

    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.

提交回复
热议问题