On Mar 6, 2012, at 1:51 PM, Jan E. Schotsman wrote:

> I have an array of progress values (number objects) for subprojects, from 
> which I calculate the overall progress .
> The array is an atomic property of the project class.
> 
> Is it safe to access this array from multiple threads, using methods like 
> objectAtIndex and replaceObjectAtIndex?

Probably not; however, if you implement the KVO indexed accessors for to-many 
properties, described here:

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830-BAJEDEFB

and guard each accessor with a mutex, spinlock, etc., you should then be able 
to use -mutableArrayValueForKey: to return an NSMutableArray proxy that you can 
use like an ordinary NSMutableArray, but which will call your now-atomic 
indexed accessors to get at the contents of the array.

Charles
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to