Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use __bridge_transfer and __bridge [duplicate]

  1. Can any one explain me what is '__bridge_transfer' and '_bridge' & when to use '_bridge_transfer' and '__bridge'
  2. I read something like its deals with ARC, So what is the main function of these both

Thanks,

like image 406
user2361155 Avatar asked Jan 13 '23 23:01

user2361155


1 Answers

These keywords are used to tell to ARC system how to handle your non-objective-c pointers. In essence, if you use __bridge, you are telling to ARC not to deal with the ownership of the converted pointer because you will free it from non-objective-c code, most likely with a free() or a CFRelease... type function. __bridge_transfer, on the other hand, transfers the ownership to ARC and ARC will free your objective-c (and thus also the original non-objective-c) object via the standard release mechanism when the references to that object hits zero.

like image 76
MrTJ Avatar answered Jan 22 '23 16:01

MrTJ