What if I used NSInvocationOperation like this:

NSInvocationOperation *myOperation = [[NSInvocationOperation alloc] 
initWithTarget:self
    selector:@selector(doResourceHungryTask) object:nil];
[operationQueue addOperation:myOperation];

"doResourceHungryTask" would be a method in my delegate class. Would I still 
need to lock/unlock (I'm modifying the class's properties from itself, not 
another class)? I'm not sure on the exact workings of NSInvocationOperation, I 
just found out about it.


On 2009-12-14, at 6:02 PM, Nick Zitzmann wrote:

> 
> On Dec 14, 2009, at 5:54 PM, PCWiz wrote:
> 
>> Its being loaded into an NSOperationQueue, and I'm using methods like 
>> setObject:forKey: on the dictionary, not replacing the whole thing.
> 
> Then you need to lock and unlock everything that reads from or writes to the 
> dictionary. Properties are no substitute for locking/unlocking the object, 
> because atomic properties will protect the instance variable, but they won't 
> protect the contents of the instance variable. @synchronized is the easy way 
> of doing this, but depending on your needs, you might need NS(Recursive)Lock 
> instead.
> 
> 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

Reply via email to