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

  • Home
  • SEARCH
  • 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 897635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:54:56+00:00 2026-05-15T14:54:56+00:00

These are setter and getters. -(NSMutableArray*)contactList { return contactList; } -(void)setContactList:(NSMutableArray*) aContactList { [contactList

  • 0

These are setter and getters.

-(NSMutableArray*)contactList
{
    return contactList;
}
-(void)setContactList:(NSMutableArray*) aContactList
{
    [contactList release];
    contactList=aContactList; //its working fine but leaks 
    // contactList=[aContactList copy]; 
    //   If I keep like this getting exception as mutating 
    //   object setting to immutable but it is mutable only. 
}

In view controller, in edit functionality, I am adding new object to the list like this

[tempDetailsObj.contactList addObject:editcontacts];

here I am getting exception as mutating

object setting to immutable but it is mutable only.

If I remove copy its working fine but I am getting Leak, So I want to add the object to the list without any exception and it should not produce any leaks.

  • 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-15T14:54:56+00:00Added an answer on May 15, 2026 at 2:54 pm

    For starters, you are not taking ownership of the parameters passed to your setter. Also you’ll want to copy mutable instances to avoid them being changed under you.

    Use e.g. this:

    - (void)setContactList:(NSMutableArray *)aContactList {
        NSMutableArray *tmp = contactList;
        contactList = [aContactList mutableCopy];
        [tmp release];
    }
    

    But then, why not use just use declared properties:

    // interface:
    @property (nonatomic, copy) NSMutableArray *contactList;
    
    // implementation:
    @synthesize contactList;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Examining Zend Framework, I found that all setter methods (of those I’ve examined) return
These are the memory leaks that I am getting: http://twitter.com/AWEHOFFICIAL/status/221182174811004929/photo/1/large
These days I design some algorithms in python, but find first two greatest value
These are for two separate codecademy exercises. They both pass me but I'm not
(Note: these two questions are similar, but more specific to ASP.Net) Consider a typical
i created a nsarraycontroller to display its data on my nstableview. this is working.
Possible Duplicate: Why use getters and setters? I know this is very trivial. But
In my class I have these setters/getters: public int Id { get; set; }
I am working with several Spring MVC web applications and I use the getter/setter
Possible Duplicate: Why use getters and setters? Is there any advantage to making methods

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.