Re: Private, Protected methods in Obj C?
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.