What is objc_sync_exit (self)

I saw that this function is used in the textDidChange UISearchBarDelegate method. I looked through all the documentation and could not think of anything. Just wondering if anyone can shed light on what this feature does.

objc_sync_exit(self) 
+5
source share
1 answer

When you write synchronized code to stop executing something more than once at a time (Objective-C: "@synchronized"), which translates into calls to objc_sync_enter () and objc_sync_exit () calls backstage.

If you notice that someone uses these functions directly, this suggests that they cannot use the simple old synchronized block (or their own Swift shell for it), because their code breaks somehow - the synchronization starts and ends in different places.

Here's a nice Swift implementation that wraps this code similarly to Objective-C.

+2
source

Source: https://habr.com/ru/post/1237983/


All Articles