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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:54:32+00:00 2026-05-14T05:54:32+00:00

I started dealing with NSOperations and (as usual with concurrency) I’m observing strange behaviour.

  • 0

I started dealing with NSOperations and (as usual with concurrency) I’m observing strange behaviour.
In my class I’ve got an instance variable:

    NSMutableArray *postResultsArray;

when one button in the UI is pressed I initialize the array:

postResultsArray = [NSMutableArray array];

and setup the operations (together with dependencies).

In the operations I create a custom object and try to add to the array:

PostResult *result = [[PostResult alloc] initWithServiceName:@"Sth" andResult:someResult];
[self.postResultsArray addObject:result];

and while adding I get:

-[CFArray retain]: message sent to deallocated instance 0x3b40c30

which is strange as I don’t release the array anywhere in my code (I did, but when the problem started to appear I commented all the release operations to be sure that they are not the case). I also used to have @synchronized section like below:

PostResult *result = [[PostResult alloc] initWithServiceName:@"Sth" andResult:someResult];
    @synchronized (self.postResultsArray) {
        [self.postResultsArray addObject:result];
    }

but the problem was the same (however, the error was for the synchronized operation).

Any ideas what I may be doing wrong?

  • 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-14T05:54:33+00:00Added an answer on May 14, 2026 at 5:54 am
    postResultsArray = [NSMutableArray array];
    

    [NSMutableArray array] is a convient method which is equivalent to [[[NSMutableArray alloc] init] autorelease]. So there is an implicit (auto)release there. Since you’re going to keep it, you have to use one of these 3 changes:

    1. postResultsArray = [[NSMutableArray array] retain];
      
    2. postResultsArray = [[NSMutableArray alloc] init];
      
    3. Exploit the fact that a setter should retain the new value (if you declare as @property(retain)):

      self.postResultsArray = [NSMutableArray array];
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started developing an application in Silverlight that was dealing with downloading the HTML
I'm looking to have a class (subclassed from threading.Thread) that is initialised and started
Working on a database class that got quite big, and is likely to get
I'm dealing here with a new problem. I started with the following code: -(IBAction)
We have a very strange issue that we're dealing with. We have an MVC
I've started reading Algorithms and I keep wondering, when dealing with primitives of the
Started with this question: OpenID. How do you logout OK. So OpenID does not
Started working on a new application this week that is running the latest rails
Started learning Wicket after ASP.NET MVC and feel a little bit confused about managing
I started trying to play with Mono, mostly for fun at the moment. 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.