On Dec 14, 2009, at 9:07 PM, PCWiz wrote: > So to make it clear, I invoke the method as an NSInvocationOperation then in > the method I do this whenever I need to access the mutable dictionary: > > - (void)doResourceHungryTask { > ... > @synchronized (myDictionary) { > [myDictionary setObject:anObject forKey:@"testKey"]; > } > } > > Is that correct?
You must lock and unlock the dictionary **every** time you read from or write to it, not just that one time. Otherwise one thread could access it at the same time as another thread is writing to it, and that would not be good. Nick Zitzmann <http://www.chronosnet.com/> _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com