• 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
Re: ARC and CFType release callback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARC and CFType release callback


  • Subject: Re: ARC and CFType release callback
  • From: Dave Keck <email@hidden>
  • Date: Wed, 20 Jun 2012 01:19:04 -0400

> Once you have a CFTypeRef via CFBridgingRetain(), ARC doesn't care what you do with it. Convert it to and from uintptr_t, pass it through a void*, send it around via IPC, whatever.

That makes sense. I'm also looking for a pattern similar to this RR
code, so that I can leave out explicit CFReleases:

    CGPatternRef pattern = [(id)CGPatternCreate(...) autorelease];
    CGColorRef color = [(id)CGColorCreateWithPattern(...) autorelease];

Is this pattern possible in ARC? I know I could use something like this:

    id pattern = CFBridgingRelease(CGPatternCreate(...));
    id color = CFBridgingRelease(CGColorCreateWithPattern(...));

But losing the variable type information isn't worth using ARC. I
figured I could make a special function:

    static void *MyCFAutorelease(CFTypeRef object)
    {
        return (__bridge void *)CFBridgingRelease(object);
    }

and use code that looks like:

    CGPatternRef pattern = MyCFAutorelease(CGPatternCreate(...));
    CGColorRef color = MyCFAutorelease(CGColorCreateWithPattern(...));

But this code isn't safe under ARC is it? I would think that since
they're CFTypes, they're invisible to ARC and can be deallocated
early.

Thanks!

David
_______________________________________________

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: ARC and CFType release callback
      • From: Greg Parker <email@hidden>
References: 
 >ARC and CFType release callback (From: Dave Keck <email@hidden>)
 >Re: ARC and CFType release callback (From: Greg Parker <email@hidden>)
 >Re: ARC and CFType release callback (From: Dave Keck <email@hidden>)
 >Re: ARC and CFType release callback (From: Greg Parker <email@hidden>)

  • Prev by Date: Intercepting spawned URL requests from UIWebView and caching the response
  • Next by Date: Fwd: SBSendMail
  • Previous by thread: Re: ARC and CFType release callback
  • Next by thread: Re: ARC and CFType release callback
  • Index(es):
    • Date
    • Thread