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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:28:20+00:00 2026-05-27T16:28:20+00:00

I have a property declared like this: @property (nonatomic, retain) NSMutableArray *pricingLevels; And I

  • 0

I have a property declared like this:

@property (nonatomic, retain) NSMutableArray *pricingLevels;

And I assign it like this:

 self.pricingLevels = [[[NSMutableArray alloc] init];

in my dealloc I have this:

self.pricinglevels=nil;

When I analyze my code with xCode it says I have a memory leak here:

self.pricingLevels = [[[NSMutableArray alloc] init];

Should I be using an autolrelease on this because the self.pricinglevels holds a reference to the array also?

  • 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-27T16:28:21+00:00Added an answer on May 27, 2026 at 4:28 pm

    self.pricingLevels is a property declared as retained which means every time you set it thru property assignment (the dot-syntax OR the method), the object automatically retains the object for you.

    self.pricingLevels = [NSMutableArray array];
    [self setPricingLevels:[NSMutableArray array]];
    

    The above code will do the same and automatically retain the array passed. This is what happens under the hood (or something similar). This method gets called:

    - (void)setPricingLevels:(NSMutableArray *)a {
        if(_pricingLevels != a) {
            [_pricingLevels release];
            _pricingLevels = [a retain];
        }
    }
    

    You see? Automatically retained, while the previous value automatically gets released.

    EDIT to answer your last question: Yes you should call autorelease

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

Sidebar

Related Questions

I have three NSString properties declared like this: @property(nonatomic,retain) NSString *currentPassword; @property(nonatomic,retain) NSString *newPassword;
Suppose I have an @property declared like this: @property (readwrite,retain) NSObject *someObject; And I
I have a NSString declared in the interface part: @property (nonatomic, retain) NSString *filePath;
I have a workflow with a property in it, declared like this: public Person
I have a div with float:right (no position property declared). This div has some
I have an object Foo that has an NSNumber property which is declared like
I have a RESTful WCF service with a method declared like this: [OperationContract(Name =
Using ARC, I have a declared property of the following form: @property (nonatomic, strong)
I have a property on a domain object that is declared in a many-to-one
I have an attribute declared on property. How can I get the property name

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.