On Aug 12, 2013, at 10:36 AM, Koen van der Drift <[email protected]> 
wrote:

> dispatch_apply(count, queue, ^(size_t i)
> {
>       myArray[i] = [self doCalculation: i];
> });

NSMutableArray isn’t thread-safe. You’ll need to synchronize/serialize the 
assignments somehow. You could do something like

{
        id value = [self doCalculation: i];
        @synchronized(myArray) {
                myArray[i] = value;
        }
}

although there is probably some nicer GCD API to do the same thing.

—Jens

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to