Re: Private methods in ObjC
Re: Private methods in ObjC
- Subject: Re: Private methods in ObjC
- From: Ondra Cada <email@hidden>
- Date: Wed, 25 Feb 2004 23:55:28 +0100
On Wednesday, Feb 25, 2004, at 17:23 Europe/Prague, Jason Vowell wrote:
I note there's no direct way of making your ObjC methods private to
clients. What's the usual idiom for doing this?
1. Define a category on the object and put it into the .m file?
2. Declare methods in the interface but preface them with something?
3. Don't declare the methods in the interface, but simply use them from
your code. Presumeably then you have to define those private methods
first in the .m implementation before you call them?
4. Put comments like "don't touch!" -- just joking...
5. Any funky techniques like multiple interface declarations?
Just use 3 with a touch of 1 if and when needed.
in *some* cases it may be worth using a private subclass, i.e.,
something like a class cluster, but with one private subclass only.
Depends on the programmer, there is no definite answer when and when
not...
And do use a nice prefix, since defining a "private" method named, say,
"length", is not the best idea: remember that there is nothing as a
private method, all methods are equally public.
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.