Re: ObjC Method naming
Re: ObjC Method naming
- Subject: Re: ObjC Method naming
- From: Enrique Zamudio <email@hidden>
- Date: Mon, 28 May 2001 16:55:20 -0500
- Organization: Nasoft
A feature of Objective-C is that you can have methods names that take
parameters in between. Following your example, the method name is
-setWidth:height: (the - indicates that it's an instance method) or you
can just call it setWidth:height:
A colon in a method name indicates that a parameter is expected right
there. So setWidth:height: expects two parameters. The cool thing about
this is that you can specify what kind of parameter you can expect, so
you know that the setWidth:height: method expects first the width, then
the height. The equivalent in java could be something like
setWidthAndHeight(float w, float h). Method names in java are restricted
to putting the complete name first and then all the parameters.
The java bridge does something funny with that, I'm not sure how it
works but at its simplest form I think it converts between method names
of the form setabc::: in ObjC to setabc(a, b, c) in java.
You are going to run into a lot of method names like setWidth:height:
which expect more than one parameter and the parameters are interspersed
with the method name, so you'll get used to it eventually.
eZL