When creating a new outlet in Xcode 4 it enters the necessary code like usual, but it prefixes a _ in the header file interface (but not in the properties):
UINavigationController *_mainNavController;
UIViewController *_rootView;
it also does this in the implementation file:
@synthesize mainNavController = _mainNavController;
@synthesize rootView = _rootView;
While I can of course use them with the prefixed _, it just makes my code messy. Am I doing something horribly wrong?
Many thanks in advance.
Why don’t you use your properties (like
self.mainNavController) instead of the backing ivars directly?Read what Apple has to say about using accessor methods:
Properties encapsulate memory management code and thus reduce boilerplate.
Also, the convention of prefixing backing ivars with
_prevents you from accessing the backing ivars directly by mistake (and fail to retain an object, for example).