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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:14:12+00:00 2026-05-23T18:14:12+00:00

so when i try to run the following code, i end up with a

  • 0

so when i try to run the following code, i end up with a EXC_BAD_ACCESS error. it happens when i try to release a NSMutableArray retrievedAnalysisDataList. the array is a list of retrievedAnalysisData objects. if i try to either release the data list or if i set up the init with an autorelease, i get the same result. i’m kinda guessing it has something to do with the sorting section of the code since i don’t have this issue with the retrievedAnalysisIDarray.

any ideas?

if (tempDict != NULL) 
    {
        NSMutableArray *retrievedAnalysisDataList = [[NSMutableArray alloc] init];
        NSMutableArray *retrievedAnalysisIDarray = [[NSMutableArray alloc] init];

        for (id key in tempDict)
        {
            retrievedAnalysisData = [[RetrievedAnalysisData alloc] init];

            retrievedAnalysisData.createDate = [[tempDict objectForKey:key] objectForKey:@"createdate"];
            retrievedAnalysisData.ID = [[tempDict objectForKey:key] objectForKey:@"id"];
            retrievedAnalysisData.mode = [[tempDict objectForKey:key] objectForKey:@"mode"];
            retrievedAnalysisData.name = [[tempDict objectForKey:key] objectForKey:@"name"];
            retrievedAnalysisData.numZones = [[tempDict objectForKey:key] objectForKey:@"numzones"];
            retrievedAnalysisData.srcImg = [[tempDict objectForKey:key] objectForKey:@"srcimg"];
            retrievedAnalysisData.type = [[tempDict objectForKey:key] objectForKey:@"type"];

            //NSLog(@"\n createDate: %@ \n id: %@ \n mode: %@ \n name: %@ \n numzone: %@ \n srcimg: %@ \n type: %@", retrievedAnalysisData.createDate, retrievedAnalysisData.ID, retrievedAnalysisData.mode, retrievedAnalysisData.name, retrievedAnalysisData.numZones, retrievedAnalysisData.srcImg, retrievedAnalysisData.type);

            [retrievedAnalysisDataList addObject:retrievedAnalysisData];
            [retrievedAnalysisData release];
        }

        NSSortDescriptor *sortDescriptor;
        sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"createDate" ascending:YES] autorelease];
        NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
        NSArray *sortedRetrievedAnalysisDataList;
        sortedRetrievedAnalysisDataList = [retrievedAnalysisDataList sortedArrayUsingDescriptors:sortDescriptors];

        int count = [sortedRetrievedAnalysisDataList count];

        for (int i = 0; i < count; i++) {
            retrievedAnalysisData = [[RetrievedAnalysisData alloc] init];
            retrievedAnalysisData = [sortedRetrievedAnalysisDataList objectAtIndex:i];

            [retrievedAnalysisIDarray addObject:retrievedAnalysisData.ID];
            [retrievedAnalysisData release];
        }

        dataCenter.sortedRetrievedAnalysisDataList = sortedRetrievedAnalysisDataList;
        dataCenter.retrievedAnalysisIDarray = retrievedAnalysisIDarray;

        [retrievedAnalysisIDarray release];
        [retrievedAnalysisDataList release];

        dataCenter.isRetrieve = [NSNumber numberWithInt:1];

        [activityIndicator stopAnimating];
        [picker reloadAllComponents];

        picker.hidden = FALSE;
        pickerToolBar.hidden = FALSE;
        toolBar.hidden = TRUE;
        innerCircle.hidden = TRUE;
        outerCircle.hidden = TRUE;
        trackLabel.hidden = TRUE;
        displayGPSLabel.hidden = TRUE;

    }
  • 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-23T18:14:13+00:00Added an answer on May 23, 2026 at 6:14 pm

    Your problem lies in this section of code:

            retrievedAnalysisData = [[RetrievedAnalysisData alloc] init];
            retrievedAnalysisData = [sortedRetrievedAnalysisDataList objectAtIndex:i];
    
            [retrievedAnalysisIDarray addObject:retrievedAnalysisData.ID];
            [retrievedAnalysisData release];
    

    The first line allocates a new RetrievedAnalysisData, but then the second throws that away (leaking it) and places an object fetched from the array in the retrievedAnalysisData variable instead. You don’t own this object fetched from the array, and you don’t take ownership by calling retain. So the release on the fourth line is incorrect, releasing an object that you do not own.

    Then when you release your NSMutableArray, it tries to release the object again and you get a crash because the object is already released.

    To fix it, get rid of the useless first line, and also get rid of the incorrect release.

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

Sidebar

Related Questions

if i try to run following code in sql server 2005 i get error
When I try to run the following code (from the REPL) in Clojure: (dotimes
When I try to run the following, I get an error back from ActiveRecord
I get the following error when I try to run sample example of Google
I'm getting the following error when I try to run a simple Java JDBC
I try to run jsf application in myeclipse using jboss web server and following
I run into the following errors when i try to store a large file
When I run the following code: Public Function DeleteSessionItem(ByVal thisSessionItem As SessionItem) As Boolean
Have written a method; when I try to run it, I get the error:
The following code -scheduler.vb- simulate a Windows Service Using ASP.NET to Run Scheduled Jobs.

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.