Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6118531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:26:51+00:00 2026-05-23T15:26:51+00:00

When creating a new outlet in Xcode 4 it enters the necessary code like

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:26:52+00:00Added an answer on May 23, 2026 at 3:26 pm

    I can of course use them with the
    prefixed _.

    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:

    Sometimes it might seem tedious or
    pedantic, but if you use accessor
    methods consistently the chances of
    having problems with memory management
    decrease considerably. If you are
    using retain and release on instance
    variables throughout your code, you
    are almost certainly doing the wrong
    thing.

    Properties encapsulate memory management code and thus reduce boilerplate.

    The only places you shouldn’t use
    accessor methods to set an instance
    variable are in init methods and
    dealloc.

    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).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I avoid third party code from creating new threads, starting new VMs, or
In my code I am creating new objects of same type inside loop and
When creating a new MVC Project in VS2008 Professional (SP1 installed), I do not
*Note to view all code, follow the link I am creating new accounts. Each
I'm using the jqueryui tabs code, adding new tabs, and dynamically creating new content
I'm creating new option menu inside fragment but after reading http://developer.android.com/resources/articles/avoiding-memory-leaks.html which said to
I'm using createuser wizard for creating new users. I'm not using any membership provider.
In my Android app I'm creating new WebViews from Java code; however after I
Occationaly I see snippets of code creating new methods for objects and such that
I have byte[] of zip file. I have to unzip it without creating new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.