• 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: Private Method?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Private Method?


  • Subject: Re: Private Method?
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 07 Nov 2011 16:03:46 -0800

On Nov 6, 2011, at 2:10 PM, Bryan Harrison wrote:

> I'm reviewing some sample code and am looking at a class with a method declared in @implementation which isn't mentioned in any @interface.
>
> Is this a private method, something else entirely, or merely sloppy coding?

That’s considered a private method. (Unlike in C++ there’s no way to absolutely prevent external code from calling it, but the compiler will give you warnings if you try to do it directly.)

In Objective-C it’s considered good style to have the @interface section show *only* the public API of the class. Internal methods should go only in the @implementation. (If you need a forward declaration you can do that with a class continuation in the .m file.)

This keeps the header more readable and hides the implementation details of the class from view. It also speeds up compilation a bit, and can avoid the need to #import more headers from your .h file.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Private Method?
      • From: Sean McBride <email@hidden>
    • Re: Private Method?
      • From: Don Quixote de la Mancha <email@hidden>
References: 
 >Private Method? (From: Bryan Harrison <email@hidden>)

  • Prev by Date: Re: Allocating too much memory kills my App rather than returning NULL
  • Next by Date: Re: Allocating too much memory kills my App rather than returning NULL
  • Previous by thread: Re: Private Method?
  • Next by thread: Re: Private Method?
  • Index(es):
    • Date
    • Thread