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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:18:54+00:00 2026-05-24T16:18:54+00:00

My NSMutableArray seems to be releasing and I can’t figure out where, here is

  • 0

My NSMutableArray seems to be releasing and I can’t figure out where, here is my code:

- (void)awakeFromNib {

arrayOfData = [[NSMutableArray alloc] initWithCapacity:0];
[arrayOfData addObject:@"test"];

NSLog(@"array: %@", arrayOfData); 

}

All is well here!

Then I create a UITable and add it to the view, then I request some data, everything is normal.

        arrayOfData = [response objectForKey:@"results"];
        NSLog(@"count: %i", [arrayOfData count]);
        NSLog(@"success!");
        numberOfRows = [arrayOfData count];
        [self.myTableView reloadData];

Creating the number of rows works fine too:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

NSLog(@"test: %i", numberOfRows);
return numberOfRows;

}

Now accessing my array gets a “message sent to deallocated instance” at that line.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"MyIdentifier";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

if (cell == nil)
{
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                   reuseIdentifier:MyIdentifier] autorelease];
}


   // crashes here!
NSLog(@"array: %i", [arrayOfData count]);

if (numberOfRows){

    NSString *filename = [[arrayOfData objectAtIndex:indexPath.row] objectForKey:@"filename"];
    NSString *url  = [NSString stringWithFormat: @"http://www.web.com/dir/%@", filename];  
    [cell.imageView setImageWithURL:[NSURL URLWithString:url]
                   placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

    cell.textLabel.text = @"My Text";
}

return cell;

}

I have also have this in my header, and I used @synthesize as well

@property (nonatomic, retain) NSMutableArray *arrayOfData;

Any help would be appreciated!

  • 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-24T16:18:55+00:00Added an answer on May 24, 2026 at 4:18 pm

    It looks like you’re reassigning arrayOfData with this line:

    arrayOfData = [response objectForKey:@"results"];
    

    If that’s what you want, try this instead:

    arrayOfData = [[response objectForKey:@"results"] retain];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NSMutableArray *insideArray = [[NSMutableArray alloc] init]; NSMutableArray *outsideArray = [[NSMutableArray alloc] init]; [insideArray addObject:@Hello
arr = [[NSMutableArray alloc]init]; [arr addObject:[NSNumber numberWithInt:4]]; [arr addObject:[NSNumber numberWithInt:45]]; [arr addObject:[NSNumber numberWithInt:23]]; [arr
This loop leaks memory: int64_t i,verylongnumber; //misc. code for(i=0;i<verylongnumber;i++){ NSMutableArray *myArray = [[NSMutableArray alloc]
Here's the code: NSError *parseError; NSMutableArray *listOfObjects = [NSJSONSerialization JSONObjectWithData:[@[] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&parseError]; NSLog(@Is
NSMutableArray *a1 = [[NSMutableArray alloc] init]; NSMutableArray *a2 = [NSMutableArray array]; TempObj *obj =
When retrieving objects from an NSMutableArray in cocoa-touch is the below code ok? Should
Seems like it should be easy to add a boolean to an NSMutableArray. Assume
I have this while loop in my code. The loop seems to work fine
It seems from the bits and pieces I can scrape together that the answer
What I want to do seems pretty simple, but I can't find any answers

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.