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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:48:33+00:00 2026-06-13T22:48:33+00:00

I have this : -(NSMutableArray*)setManch:(NSMutableArray*)data { NSMutableArray *manch=[data mutableCopy] ; // some calculations on

  • 0

I have this :

-(NSMutableArray*)setManch:(NSMutableArray*)data
{

    NSMutableArray *manch=[data mutableCopy] ;
     // some calculations on manch
    return manch;

}

If i try to do :

NSMutableArray *manch=[[data mutableCopy] autorelease] ;

I get a crash .

But, i have to release this copy somehow because I call this function again and again. How should I do that?

for(int k=0;k< count;k=k+2)
    {
        if(k==count-1)
            [manch addObject:[NSNumber numberWithInt:![[manch objectAtIndex:k] integerValue] ] ];
        else
            [manch insertObject:[NSNumber numberWithInt:![[manch objectAtIndex:k] integerValue] ]     atIndex:k+1 ];
    }
  • 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-13T22:48:34+00:00Added an answer on June 13, 2026 at 10:48 pm

    I would recommend to use ARC.

    But anyway. The autorelease is correct here. So your mistake is probably somewhere else. What does the error state exactly?

    Probably the problem is the data IN your array. A simple copy call does NOT make deep copies. So if you’re objects only exist in the first array, they will be released as soon as that array gets released. Debug your data: look what exists before and after that method call.

    You should read about & understand memory management on ios:

    General Memory Management:
    http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html#//apple_ref/doc/uid/10000011i

    Practical Management, especially “Avoid Causing Deallocation of Objects You’re Using”
    http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html#//apple_ref/doc/uid/20000043-1000922

    Also read about ARC:
    http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html#//apple_ref/doc/uid/10000011i

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

Sidebar

Related Questions

I have this code to get NSStrings from an NSDictionary from an NSMutableArray but
I've been looking for this, but can't find the answer. I have an NSMutableArray
I have this function: void myFunc(NSString* data) { NSMutableArray *instrs = [[NSMutableArray alloc] initWithCapacity:[data
I have this code: tableList = [[NSMutableArray alloc] initWithObjects:@First View,@Second View,nil]; I have synthesized
I have this: NSString *string1 = ...; NSString *string2 = ...; NSMutableArray *array =
Do I have this right ... // Reactor.h @property(nonatomic, retain) NSMutableArray *reactorCore; // Reactor.m
I have an NSMutableArray of NSArray's inside it. This is my current structure: Paused
I have a variable declared like this: @property (nonatomic, retain) NSMutableArray *aInfo; At the
I have this code: for the simulator to write a NSmutableArray in a plist
I only have this code in m. file NSMutableArray * arrayOfBools; arrayOfBools=[[NSMutableArray alloc] initWithCapacity:1000];

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.