Why doesn't Xcode offer @synchronized?

I rarely use @synchronized, but as far as I remember (which means Xcode 3.2 or something else), it never suggested @synchronized when using autocomplete and still does not. I get suggestions when typing "@", for example @autorelease, @encode, @selector, etc.

Is there any known reason for this? I could not find any related topic. This annoyed me because it gives me the feeling that this is not a valid concurrency handling method in iOS.

+4
source share
1 answer

@synchronized does not appear when using automatic completion because Apple does not display this keyword for code implementation. At the suggestion of Apple, I published a bug report.

However, I can offer an autocomplete solution. You can create an @synchronized snippet that can be automatically completed or dragged into your code.

  • Copy / paste the code below into one of your Xcode documents.
  • Select the new code and drag it into the fragment library.
  • Double-click the new fragment and click "Edit."
  • Type @synchronized for the completion shortcut.

For more information: http://nshipster.com/xcode-snippets/

@synchronized(anObj) {
    // Everything between the braces is protected by the @synchronized directive.
}
0
source

All Articles