LoginSignup
4
4

More than 5 years have passed since last update.

Bridged Casts

Posted at

ARCを有効にするとCとObjective-C間のキャストをする際に
ARC無効の時の記述のままだとコンパイルエラーになります。

ということで以下3種類のBridgeCast違いを簡単に説明

__bridge

単純なキャスト
オーナーシップ権は移行しない

__bridge_retained

キャストした際に参照カウントを+1する

__bridge_transfer

オーナーシップ権が移行される

よく理解しないまま__bridge_retainedをして
いつまでたってもメモリが開放されなかったのは
いい経験でしたよ、ええ。

参考URL

Objective-C Automatic Reference Counting (ARC) 3.2.4 Bridged casts

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4