Synchronizing class methods in Objective-C
vombat.tumblr.com
Synchronizing class methods in Objective-C
1–10 of 11 posts
Re: Synchronizing class methods in Objective-C
#2Re: Synchronizing class methods in Objective-C
#3Re: Synchronizing class methods in Objective-C
#4Re: Synchronizing class methods in Objective-C
#5So, what is self inside a class method? I was under the impression it was the Class?
> The object passed to the @synchronized directive is a unique identifier used to distinguish the protected block
Re: Synchronizing class methods in Objective-C
#6Re: Synchronizing class methods in Objective-C
#7Why do you need to synchronize class methods? Global state mutation?
Re: Synchronizing class methods in Objective-C
#8So, what is self inside a class method? I was under the impression it was the Class?
Personally, if I had to ensure synchronous calls to a class variable, I'd prefer to just restrict calls like this to a specific queue using dispatch_sync().
Re: Synchronizing class methods in Objective-C
#9So, what is self inside a class method? I was under the impression it was the Class?
It is the class. But it's not the class in which the method is defined it's the class from which it is called.
So in one case it's the superclass and in the other case it's the subclass.
Re: Synchronizing class methods in Objective-C
#10Why do you need to synchronize class methods? Global state mutation?
Lazily instantiating a shared object is the obvious reason. Doesn't need to be mutable.
0 - https://developer.apple.com/library/mac/documentation/Darwin...