Questions regarding release
Questions regarding release
- Subject: Questions regarding release
- From: Gabriel Zachmann via Cocoa-dev <email@hidden>
- Date: Wed, 25 Sep 2019 21:31:49 +0200
A few years ago, I switched my code to ARC.
Now, I have this in my code:
CGImageRef imageRef = CGImageSourceCreateImageAtIndex( sourceRef, 0, NULL );
...
NSImage * nsimage = [self convertToNSImage: img withOrientation:
img_orientation];
assign nsimage to a layer
...
CGImageRelease( imageRef );
...
use the layer with the nsimage
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?
Or should I keep the imageRef until the layer itself gets removed from its
super layer?
Also, I have some more release's in my code, and I would appreciate your advice
whether or not I still need them. (Sometimes, I still get confused.)
io_service_t serv = [self IOServicePortFromCGDisplayID: displayID];
CFDictionaryRef info = IODisplayCreateInfoDictionary(serv,
kIODisplayOnlyPreferredName);
IOObjectRelease(serv);
Is the IOObjectRelease() right or wrong ?
Thanks a lot in advance.
Best regards, Gabriel
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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