On Nov 18, 2009, at 9:44 AM, Michael de Haan wrote:

> "Names of most private methods in the Cocoa frameworks have an underscore 
> prefix (for example, _fooData ) to mark them as private. From this fact 
> follow two recommendations.
> 
>       • Don’t use the underscore character as a prefix for your private 
> methods. Apple reserves this convention."

This is unfortunately true. The danger is that if you add an _-prefixed method 
to your class, it might conflict with a private method declared in a 
superclass. If this happens your method will override the internal one, and 
Really Bad Things will probably happen. It's a rare problem but it has happened 
before. (And even if everything works well now, any future OS update might add 
a new private method in a superclass that breaks your code. Again, this has 
actually happened.)

Using a naming convention for your private/internal methods is a good idea; 
just use a different convention. I've seen people use an "i_" prefix, for 
example.

—Jens_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to