> On Sep 25, 2019, at 2:52 PM, Rob Petrovec via Cocoa-dev 
> <cocoa-dev@lists.apple.com> wrote:
> 
>> Is it safe to do it after assigning the nsimage to the layer, but before 
>> deleting the layer?
>       I would think so, but it is hard to say without knowing what 
> convertToNSImage:withOrientation actually does under the hood.  It likely 
> either retains or copies it.  In either case, your release is safe & correct.
        With that said, CALayer.contents will convert the NSImage into a 
CGImageRef under the hood.  So even your NSImage won’t live for very long.

—Rob


>> Is the IOObjectRelease() right or wrong ?
>       I’m not entirely sure since I can’t find the docs for 
> IOServicePortFromCGDisplayID.  But just from the name of 
> IODisplayCreateInfoDictionary alone, info needs to be released via 
> CFRelease(info).
> 
> —Rob
> 
> 
>> On Sep 25, 2019, at 1:31 PM, Gabriel Zachmann via Cocoa-dev 
>> <cocoa-dev@lists.apple.com> wrote:
>> 
>> 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
>> 
>> 
>> _______________________________________________
>> 
>> 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/petrock%40mac.com
>> 
>> This email sent to petr...@mac.com
> 
> _______________________________________________
> 
> 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/petrock%40mac.com
> 
> This email sent to petr...@mac.com

_______________________________________________

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