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

  • SEARCH
  • Home
  • 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 8824027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:30:20+00:00 2026-06-14T06:30:20+00:00

In an iOS ARC enabled project, what happens when I don’t synthesize a property,

  • 0

In an iOS ARC enabled project, what happens when I don’t synthesize a property, since retain/release are disallowed?

@interface SomeClass : NSObject {
    NSMutableArray*     _pieces;
}
@end

What are the memory semantics of the iVar _pieces in this case?
Say I set it using, _pieces = whatever.

Is _pieces set to nil when the instance of my SomeClass is deallocated?
Is _pieces stored as a weak reference?
If all other objects that have retained _pieces release it, will it be null when I attempt to access it?

  • 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-06-14T06:30:21+00:00Added an answer on June 14, 2026 at 6:30 am

    A couple of observations, much of which is probably clear by this point based upon the feedback of others:

    1. You synthesize properties, not instance variables, and in your example, you showed us an example of an instance variable, not a property.

    2. Your question might imply some assumed connection between synthesizing and the ability to do retain/release, but there is no such connection. The ability to do retain and release is a function of whether you are using ARC or not. It has nothing to do with synthesizing properties.

    3. As others have observed, explicitly declared instance variables, such as your example, are strong references, by default. So, in your example, _pieces is a strong reference.

    4. Yes, when your SomeClass object is deallocated, it will remove its strong reference to the _pieces object. Obviously, if that’s the last strong reference to the object pointed to by _pieces it will be deallocated and any other weak references you have to it elsewhere will be set to nil. For a more complete discussion on the memory management, see Apple’s Advanced Memory Management Programming Guide and Transitioning to ARC.

    5. You asked “If all other objects that have retained _pieces release it, will it be nil when I attempt to access it?” Obviously that would be true if _pieces was a weak reference, but given that it’s implicitly a strong reference in SomeClass, no, that is not the case.

    6. If you wanted to make pieces a declared property, the syntax would be

      @property (nonatomic, strong) NSMutableArray* pieces;

      The designation of strong vs. weak (or whatever) dictates the memory management of the property.

    7. If you declare a property, you not only no longer have to explicitly define the instance variable, but rather it is now advised that you really should not do so (because when it’s synthesized, the compiler will create the ivar for you). But, if you happen to have an explicitly declared instance variable of the right name for your property, the compiler will use that for the property. But that’s not only unnecessary, but also inadvisable (because if you mistype the name of the instance variable, you may unwittingly end up with two instance variables). Just let the compiler synthesize your instance variables for your properties and this potential ambiguity goes away.

    8. The name of the instance variable that will be synthesized for a property is governed by the syntax of the property implementation directive, i.e. the @synthesize statement. Thus, if you have a @synthesize statement for your pieces property of the form:

      @synthesize pieces;

      then the instance variable will be called pieces. But if you use the preferred @synthesize syntax of:

      @synthesize pieces = _pieces;

      then the instance variable name will have the preceeding underscore (which is, by convention, preferred, to avoid ambiguity in your code between properties and instance variables). And, as of Xcode 4.4, if you omit the @synthesize statement for a @property, it will implicitly synthesize it for you with the latter syntax, i.e. the instance variable will bear the leading underscore).

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

Sidebar

Related Questions

In my iOS 5 project with ARC enabled, one of my objects gets released
I am working on an iOS SDK 4 project with ARC enabled. My class
I've converted my project to iOS 5 and enabled ARC. Now I need to
I'm using the following code within XCode, building for iOS with ARC enabled. Why
I have an iOS-App which uses ARC. I don't use InterfaceBuilder, all UI is
I'm using iOS 5 with ARC enabled. I'm playing a recording associated with a
In my iOS ARC-enabled code, I need to pass self and other objects to
Consider this simple UIView subclass in an ARC-enabled iOS app that draws on the
Note: the below is using iOS with Automatic Reference Counting (ARC) enabled. I think
When using ARC for iOS, is there any difference between the following? @property (strong,

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.