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 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 trying to play with Mono, mostly for fun at the moment. I
I started an application in Google App Engine right when it came out, to
I started using subversion for one of my projects and it would be absolutely
I started a Rails project recently and decided to use RESTful controllers. I created
I started programming C# applications when the 1.0 framework was first released. I worked
I started off programming in Basic on the ZX81 , then BASICA , GW-BASIC
Just started getting a bunch of errors on our C# .Net app that seemed
I started dabbling in groovy yesterday. There's an example on the groovy website that
I started with jetlang and the basic samples are pretty clear. What I didn't
I started a new WPF project in VS2008 and then added some code to

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.