如何编写具有多个参数的方法/消息? [英] How to write a method/message with multiple parameters?

查看:87
本文介绍了如何编写具有多个参数的方法/消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何编写具有多个参数的方法/消息?

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

我的意思是像单个方法/消息的多个参数一样.

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

推荐答案

您可以这样编写声明:

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

后续调用(带有4个参数)可能类似于:

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

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

其中,rect是先前定义的NSRect,self是从其调用方法的NSView,从嵌套方法调用获得的NSColor对象,以及常量布尔值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.

这篇关于如何编写具有多个参数的方法/消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆