开发者

Safe NSArray access

开发者 https://www.devze.com 2023-01-26 17:30 出处:网络
I expected objectAtIndex: to return a retained and autoreleased object for my use, but my tests with autorelease pools indicate they do not.

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 o开发者_如何学GobjectAtIndex but before I have a chance to use or retain that reference?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号