On Sep 25, 2019, at 12:31 PM, Gabriel Zachmann via Cocoa-dev 
<cocoa-dev@lists.apple.com> wrote:
> The doc for CGImageSourceCreateImageAtIndex() that I need to release imageRef 
> myself.
> Is it safe to do it after assigning the nsimage to the layer, but before 
> deleting the layer?

Yes, the NSImage will retain/release the image ref if it needs to keep using 
it, and the layer will retain/release the NSImage if it needs to, so that you 
don't have to worry about the exact lifetime of the CGImage or NSImage. 

As for IOObjectRelease(), the usual rule of thumb is that ARC takes care of 
ObjC retain-release but you still need to do C (CoreFoundation, etc) management 
yourself; I suppose it depends on the implementation of 
IOServicePortFromCGDisplayID: whether it expects you to release the returned 
io_service_t or not, but ARC shouldn't be doing any automatic releasing of that 
variable, since it's a mach-port and not an object.

The Xcode "analyze" step should check for errors of this kind. I have xcode set 
to analyze on every build, since it's usually not too slow.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to