Question

I expected objectAtIndex: to return a retained and autoreleased object for my use, but my tests with autorelease pools indicate they do not.

This being the case, how do I protect myself against another thread removing an object from an array after I retrieve its reference using objectAtIndex but before I have a chance to use or retain that reference?

Was it helpful?

Solution

Synchronize access to the array, as you should any access to resources shared across threads.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top