Why does casting a CGImageRef to an object pointer require no memory management info (__bridge etc.)? For example, if image is of type UIImage *, and layer is a UIView's underlying layer, then the following line of code does not elicit any complaints from the compiler:
layer.content = (id)[image CGImage];
To quote Transitioning to ARC Release Notes:
The Compiler Handles CF Objects Returned From Cocoa Methods
The compiler understands Objective-C methods that return Core Foundation types follow the historical Cocoa naming conventions (see Advanced Memory Management Programming Guide). For example, the compiler knows that, in iOS, the CGColor returned by the CGColor method of UIColor is not owned. You must still use an appropriate type cast, as illustrated by this example...
(OK, not quite cocoa-touch, but hey!).
Because CGImage returns a CoreFoundation object, a __bridge
cast isn't required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With