• 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: Are method declarations just comments?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Are method declarations just comments?


  • Subject: Re: Are method declarations just comments?
  • From: Peter Ammon <email@hidden>
  • Date: Mon, 09 Jul 2001 11:07:29 -0700

on 7/8/01 2:27 AM, Andreas Monitzer at email@hidden wrote:

> On Sunday, July 8, 2001, at 08:52 , Chris Gehlker wrote:
>
>> I'm pretty new to Cocoa, just working my way through "Learning Cocoa" in
>> fact. I noticed that the book was having me add methods in .m files
>> without
>> declaring them in the corresponding .h file and the programs were still
>> compiling and running w/o warnings. So I went back and commented out
>> method
>> declarations and even changed them so they declared the wrong type of
>> arguments. Again it didn't seem to matter. I'm beginning to fear that
>> they're just comments. Someone say it isn't so.
>
> It isn't so :-)
>
> Header files are in ObjC (like in C, unlike in C++) just a hint for the
> compiler and for the user. You can send every message you like to every
> object, but if it's not declared in the header, the compiler will spit out
> a warning.

Unless I'm mistaken, Objective-C is actually more lax about requiring
function declarations. For example, C requires that variadic functions
(that is, functions with a variable number of arguments like printf) be
prototyped, whereas AFAIK Objective-C places no such requirements on
variadic methods (e.g. arrayWithObjects:)

-Peter


  • Follow-Ups:
    • Re: Are method declarations just comments?
      • From: Chris Gehlker <email@hidden>
    • Re: Are method declarations just comments?
      • From: Andreas Monitzer <email@hidden>
References: 
 >Re: Are method declarations just comments? (From: Andreas Monitzer <email@hidden>)

  • Prev by Date: Re: Distributed Objects over Network
  • Next by Date: Obj-C wrapper for zlib
  • Previous by thread: Re: Are method declarations just comments?
  • Next by thread: Re: Are method declarations just comments?
  • Index(es):
    • Date
    • Thread