• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ObjC Method naming
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ObjC Method naming


  • Subject: Re: ObjC Method naming
  • From: Andreas Monitzer <email@hidden>
  • Date: Tue, 29 May 2001 00:18:58 +0200

On Monday, May 28, 2001, at 11:12 , Scott wrote:

Does this mean that I could write my method calls as:

[myRect setWidth:10.0, 10.5];

Would it be acceptable without any parameter names, just commas? Or, do I
have to use colons?

[myRect setWidth:10.0 :10.5];

I think you have to use colons, except when using an indefinite number of arguments (like printf and scanf).

Just trying to get as close to a c++ style calling structure as possible
since that's the way my brain's wired right now. Fewer keystrokes is
better.

Yes, but more verbosity helps making the code more readable (this isn't the obfuscating C contest!)

- (void)setWidth:(float)a height:(float)b;

vs.

- (void)set:(float)a :(float)b;

or

#define f float
#define v void
-(v)s:(f)a:(f)b;

;-)

Also, what does the minus sign ("-") mean in the declaration? I've seen the
plus sign used also. What's the difference? All it says in the docs is
"you could also use the plus sign..." but doesn't follow up with any meaning
behind it.

+ is called "static" in C++. Isn't not really the same, since in ObjC there's one class object (one global instance) that's accessed this way, but you can treat it like static.

And when I declare a method, do I HAVE to declare it with
parameter names or can I leave them out?

Ex.
- (void) setWidth:(float) w height:(float) h

Don't think so, but I've never tried.


andy
--
Description forthcoming.


References: 
 >Re: ObjC Method naming (From: Scott <email@hidden>)

  • Prev by Date: Re: ObjC Method naming
  • Next by Date: Re: Exceptions
  • Previous by thread: Re: ObjC Method naming
  • Next by thread: Re: ObjC Method naming
  • Index(es):
    • Date
    • Thread