When to use __bridge_transfer and __bridge

  • Can someone explain to me what __bridge_transfer and _bridge are, and when to use _bridge_transfer and __bridge
  • I read something like my deals with ARC. So what is the main function of these two

Thanks,

+4
source share
1 answer

These keywords are used to tell the ARC system how to handle non-objective-c pointers. In essence, if you use __bridge, you say ARC to not own the converted pointer, because you will free it from non-objective-c code, most likely using the free () or CFRelease ... type function. On the other hand, __bridge_transfer transfers ownership of ARC, and ARC will release your objective-c (and therefore also the original objective-c object) through the standard release mechanism when references to this object reach zero.

+9
source

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


All Articles