Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should really check out the ARC videos from WWDC 2011. They are available on the developer site and open through iTunes. Especially:</p> <blockquote> <p>• Session 323 – Introducing Automatic Reference Counting </p> <p>• Session 322 – Objective-C Advancements in Depth</p> </blockquote> <p>Also, the ARC reference notes:</p> <blockquote> <p><a href="https://developer.apple.com/library/content/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html" rel="nofollow noreferrer">https://developer.apple.com/library/content/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html</a></p> </blockquote> <p>Both the reference notes and the videos discuss Core Graphics (et al) and how they work with ARC. </p> <p>Specifically, look at the section called <strong>"Managing Toll-Free Bridging"</strong></p> <blockquote> <p>In many Cocoa applications, you need to use Core Foundation-style objects, whether from the Core Foundation framework itself (such as CFArrayRef or CFMutableDictionaryRef) or from frameworks that adopt Core Foundation conventions such as Core Graphics (you might use types like CGColorSpaceRef and CGGradientRef).</p> <p>The compiler does not automatically manage the lifetimes of Core Foundation objects; you must call CFRetain and CFRelease (or the corresponding type-specific variants) as dictated by the Core Foundation memory management rules (see Memory Management Programming Guide for Core Foundation).</p> <p>If you cast between Objective-C and Core Foundation-style objects, you need to tell the compiler about the ownership semantics of the object using either a cast (defined in objc/runtime.h) or a Core Foundation-style macro (defined in NSObject.h): [...]</p> </blockquote> <p>Jörg Jacobsen has a good summary overview of the bridging options as well: <a href="http://www.joergjacobsen.com/blog/2011/10/05/managing-toll-free-bridging-in-an-arced-environment/" rel="nofollow noreferrer">Managing Toll-free Bridging in an ARC’ed Environment</a>.</p> <blockquote> <p><strong>__bridge_retained</strong> (n.b.: only use it when casting from object pointer to C type pointer): I (the programmer) need to reference this object for some time in the dark world of C type pointers which is opaque to you, ARC. So please, please do not release this object while I still need it. I (the programmer) promise to release it myself (in the dark world) when I’m done with it</p> <p><strong>__bridge_transfer</strong> (n.b.: only use it when casting from C type pointer to object pointer): I (the programmer) hand over to you, ARC, an object that I own and that I am no longer interested in in the dark world of C type pointers that is opaque to you. Whenever you, ARC, are done with that object please release it yourself, because you know the right time and thus save me some work not having to do it myself.</p> <p><strong>__bridge</strong>: ARC, you keep balancing out your retains and releases as I keep balancing out mine in the dark world of C type pointers which is…. Whenever I need to hold on to an object in the dark world I will retain it myself and release it when appropriate. I don’t need any extra contract with you, ARC.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload