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 6054765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:11:23+00:00 2026-05-23T08:11:23+00:00

I am new to iOS so take me slow. When i declare an object

  • 0

I am new to iOS so take me slow. When i declare an object in my .h view controller named “_a” and i declare a property “a” and when i synthesize in the .m file

@synthesize a=_a;

must i use “a” or “_a” when i modify that object ? ( “a” is a UINavigationController in my case).

In another question, does my compiler automatically draw a connection from a object declared “ob” to a “_ob” declaration ?

Again, sorry for the poor explanation but this environment isn’t quite something i am use to.

  • 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-23T08:11:23+00:00Added an answer on May 23, 2026 at 8:11 am

    An object declared like this:

    @interface Example : NSObject {
        NSObject *_a;
    }
    @property (retain) NSObject *a;
    @end
    

    And implemented like this:

    #import "Example.h"
    
    @implementation Example
    @synthesize a = _a;
    @end
    

    Makes an ivar named _a and two accessor methods in the Example object. The accessor methods have these signatures:

    - (NSObject *)a;
    - (void)setA:(NSObject *)theA;
    

    Method a returns the object in the _a ivar. Method setA releases the object stored in _a (if not nil), assigns the parameter to _a, and sends the parameter an retain message.

    These methods may also be access through dot notation:

    Example *e = [[Example alloc] init];
    // These two are equivalent. 
    e.a = anotherNSObject;
    [e setA:anotherNSObject];
    // These two are equivalent.
    anotherNSObject = e.a;
    anotherNSObject = [e a];
    

    Accessing _a directly will circumvent the accessor methods, potentially causing problems such as memory leaks. For example if _a holds the only reference to an object and a new object reference is assigned to _a the old object will become a leaked object.

    To directly answer your two questions:

    You may use either a or _a. In most cases you’ll be better off using _a when reading the value within methods of the object declaring a, and setA (or a in dot notation) when setting the value of _a. Objects that use Example objects should use the accessor methods (with or without dot notation).

    The complier does not automatically make a connection between ob and _ob declarations. In this example the @synthesize a = _a; statement makes the connection with the optional = _a. The ivar may have any name. @synthesize a = george; would also be valid. Without the = _a part the compiler would make an ivar named a and two accessor methods.

    One further note: You may omit the declaration of _a in the interface, which restricts the scope of the _a ivar to just the implementation of the Example object. Adding the optional = _a to the @synthesize statement will make as ivar of the same type as the property declared in the interface.

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

Sidebar

Related Questions

I'm new to iOS developement... I want to add 3 buttons on this view:
I've started to use the new iOS 5 brightness setter in UIScreen. Is there
I am quite new to iOS development and just thought to take guidance from
Very new to programming for iOS and Cocoa so please take it easy on
I've been looking at the new OpenGL framework for iOS, aptly named GLKit, and
I just started a new iOS project and chose to use Core Data with
I'm new to iOS development, and I'm having a problem with reused view controllers.
New class is a subclass of the original object It needs to be php4
New to xml. Looking for XPath to search a xml file with python ElementTree
New day, new problem :-) Code: Client Side: void abw_Closed(object sender, EventArgs e) {

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.