Does @synchronized(self) create a block where the self prefix is unecessary on properties?

Please read this Documentation

The @synchronized() directive locks a section of code for use by a single thread. Other threads are blocked until the thread exits the protected code—that is, when execution continues past the last statement in the @synchronized() block.

The @synchronized() directive takes as its only argument any Objective-C object, including self.

As Massimo Cafaro pointed out: "It’s safest to create all the mutual exclusion objects before the application becomes multithreaded, to avoid race conditions."


@synchronized(self) is used to get rid of the self. prefix.

So in my example I set the strText not in the function I set it in the class.

Two concepts are being conflated.

  1. @synchronized(self) { ... } only locks the block using the self object as the semaphore.
  2. In Objective-C, there is nothing like a hypothetical with statement as in other languages that removes the need for self.whatever to be just whatever. Might want to take the Stanford CS193P online course to brush up on the language.