Re: Questions regarding release
Re: Questions regarding release
- Subject: Re: Questions regarding release
- From: Wim Lewis via Cocoa-dev <email@hidden>
- Date: Wed, 25 Sep 2019 13:57:42 -0700
On Sep 25, 2019, at 12:31 PM, Gabriel Zachmann via Cocoa-dev
<email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden