• 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, Protected methods in Obj C?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Private, Protected methods in Obj C?


  • Subject: Re: Private, Protected methods in Obj C?
  • From: Shawn Erickson <email@hidden>
  • Date: Wed, 3 Apr 2002 08:55:27 -0800

On Wednesday, April 3, 2002, at 06:13 AM, John Hvrnkvist wrote:

On Wednesday, April 3, 2002, at 03:51 PM, Jed wrote:

Hi.

Starting to get my head round moving code from C++ to Obj C and have the following problem. An Obj C class can have private, protected and public variables, not a problem, but I can't find any syntax for protecting methods in the same way!

This seems off topic for the list; wouldn't Cocoa-dev be better?

Good idea... moving it.

I can't believe all Obj C Class methods can only be public.
Any pointers much appreciated.

All methods are public. If you want to hide methods you can declare categories within the implementation file. This doesn't mean they can't be accessed, though.

If you really want private methods, the closest you can get is writing static C functions within the scope of the class implementation.

It is my understanding that private methods shouldn't be listed in your interface definition (@interface - @end block). Basically the interface definition for a class contains all externally usable methods (lists the message the class supports). Sure an external class could still guess at messages you support but...

This is close to private methods in C++. Not not sure about an equivalent for protected methods...

-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Private, Protected methods in Obj C?
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: about kernel's subcomponents...
  • Next by Date: Cursor
  • Previous by thread: Re: Highlighting Column Headers
  • Next by thread: Re: Private, Protected methods in Obj C?
  • Index(es):
    • Date
    • Thread