• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Questions regarding release
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Questions regarding release
      • From: Wim Lewis via Cocoa-dev <email@hidden>
    • Re: Questions regarding release
      • From: Rob Petrovec via Cocoa-dev <email@hidden>
  • Prev by Date: Re: NSMenuItem : acceptsFirstMouse(forEvent: NSEvent)
  • Next by Date: Re: Questions regarding release
  • Previous by thread: How to have users select a directory
  • Next by thread: Re: Questions regarding release
  • Index(es):
    • Date
    • Thread