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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:20:17+00:00 2026-06-01T09:20:17+00:00

I have a variable declared like this: @property (nonatomic, retain) NSMutableArray *aInfo; At the

  • 0

I have a variable declared like this:

@property (nonatomic, retain) NSMutableArray *aInfo;

At the beggining, if I declare the variable like this:

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

In every point of the app, I can stop the execution with a break point and print the variable content like this:

po self.aInfo

BUT, if I declared the variable with autorelease (as it should be), I cannot see the content anymore in my breakpoint…

self.aInfo = [[[NSMutableArray alloc] init] autorelease];

PD: If I do something like NSLog(@”%@”, self.aInfo) I can see the content…

  • 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-01T09:20:18+00:00Added an answer on June 1, 2026 at 9:20 am

    if I declared the variable with autorelease (as it should be)…

    As it shouldn’t be. Try this:

    NSMutableArray *aNewArray = [[NSMutableArray alloc] init];
    self.aInfo = aNewArray;
    [aNewArray release];
    

    Or use a convenience method, which is in the autorelease pool and which you do not own, so it can be assigned directly:

    self.aInfo = [NSMutableArray array];
    

    or:

    self.aInfo = [NSMutableArray arrayWithCapacity:20]; // use whatever number makes sense
    

    Remember that when you set up your property to “retain,” it does just that. Its synthesized accessors will release the old assignment and retain the new one. So if you assign an alloc’d instance to it directly, that instance will be retained twice, creating a memory leak.*

    *Edit: See deanWombourne’s comments below. alloc] init] autorelease as a direct assignment to a retained property will not create a memory leak. But I remain unconvinced that it is memory-efficient.

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

Sidebar

Related Questions

I have a variable declared like this in a class: Entity *array[BOARD_SIZE][BOARD_SIZE]; I need
I have a NSString declared in the interface part: @property (nonatomic, retain) NSString *filePath;
I have an array and a variable declared like this NextPacketRegister : array (1
I have a class level price variable decalred inside a page, like this: public
I have declared this variable in jquery var enabled = false; I want to
unordered_map<std::string,unordered_map<std::string, std::string> >* storing_vars; I have this variable in the scope declared in the
I have declared a DLL import in my C# program that looks like this:
Say I have classes declared like this: public abstract class IdentifiableEntity { public boolean
I have three variable declared as doubles: double Delay1 = 0; double Delay2 =
Suppose I have a static variable declared inside a function in C. If I

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.