Theocacao
Leopard
Design Element
Comment on "A Quick Objective-C 2.0 Tutorial: Part II"
by Scott Stevenson — Nov 04
@Ross Carter, @britt:

Britt sent me some contributions to THCanvasView, and this topic came up. I've always used underscores as a prefix for ivars and private methods. Britt convinced me that this isn't such a great idea for private methods because collisions with built-in frameworks are possible but I still think it's okay for ivars. There was no particular reason I left them out in this case.

@britt: Scott and I both agree that Apple's recommendation to name private components with a prefix (like this: XY_doSomethingAmazing) is really ugly to read

Just to be clear, I don't think the XY_ syntax is actually a recommendation, as much as it is a suggestion. The only real recommendation is avoid single and double-underscores at the beginning of a method name.

For true private ivars (and yes, I do know that this makes you grimace, Scott :-) where by that I mean an ivar that should not be available to subclasses at all, I declare them @private and do not create accessors for them

The reason I grimmace is that I've seen countless problems with bindings, KVC, and memory management where people blame the frameworks, only to discover that using accessors solves all of it. You can get and set instance variables directly if you really need to, but I think it just complicates life with no real benefits.
Back to "A Quick Objective-C 2.0 Tutorial: Part II"
Design Element

Copyright © Scott Stevenson 2004-2015