Message sent to deallocated instance which has never been released
Posted
by Jakub
on Stack Overflow
See other posts from Stack Overflow
or by Jakub
Published on 2010-04-11T12:57:14Z
Indexed on
2010/04/11
13:03 UTC
Read the original article
Hit count: 244
Hello,
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?
© Stack Overflow or respective owner