• 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: Instance method declaration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Instance method declaration


  • Subject: Re: Instance method declaration
  • From: Erik Buck <email@hidden>
  • Date: Sun, 21 May 2006 22:41:41 -0400

Hi,

Is declaration of instance method in the header file optional?

Yes.

However, declarations in header files are typically necessary to achieve warning free compilations particularly when multiple files and classes are included in the compilation.

More importantly, on some hardware platforms, different Objective-C runtime functions are called based on the expected return type of the message being sent. For example, if the message is expected to return a double or a structure, the location such as register vs. stack of the return value can be best handled by the runtime only if the expected return type is known at compile time. For messages that return pointers or pointer sized values, there is no issue.

Finally, keep in mind that even when all type information is provided at the time of compilation, Objective-C can not positively assume any particular type information because it is explicitly acceptable to send any message to any object including anonymous objects and objects in other processes via distributed objects. If the receiver of a message can not respond to the message, a runtime error is typically generated.

All of this information is conveniently already on your hard disk and online:
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/ Articles/chapter_4_section_1.html
developer.apple.com/documentation/ Cocoa/Conceptual/ObjectiveC/ObjC.pdf


From the documentation
"The Role of the Interface ... methods that are internal to the class implementation can be omitted."


It is also worth mentioning that just like not all implemented methods have to be declared in the interface, is not always necessary to implement all declared methods. Reference "informal protocol" in the documentation.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Runtime difference on "some" hardware? (Was: Re: Instance method declaration)
      • From: Sherm Pendley <email@hidden>
    • Re: Instance method declaration
      • From: Sherm Pendley <email@hidden>
  • Prev by Date: Re: Problem connecting to Oracle 10g via 'Instant Client's dylibs'
  • Next by Date: Re: Instance method declaration
  • Previous by thread: Re: Instance method declaration
  • Next by thread: Re: Instance method declaration
  • Index(es):
    • Date
    • Thread