Re: CFDictionarySetValue and ARC
Re: CFDictionarySetValue and ARC
- Subject: Re: CFDictionarySetValue and ARC
- From: Greg Parker <email@hidden>
- Date: Mon, 17 Oct 2011 12:50:23 -0700
On Oct 15, 2011, at 8:20 PM, Roland King wrote:
> I don't think I want either __bridge_transfer or __bridge_retained, the former is for passing things back to obj-c classes and the latter I believe effectively transfers ownership and would require an extra CFRelease() which isn't going to happen, I don't want to transfer ownership, the dictionary will take its own ownership.
If you are familiar with retain/release logic then you may find that CFBridgingRetain() and CFBridgingRelease() make more sense than __bridge_transfer and __bridge_retained.
CFBridgingRetain() converts id to void* and retains it. You must balance it with a subsequent CFRelease() or CFBridgingRelease(). Let ARC do what it wants with the id side.
CFBridgingRelease() converts void* to id and releases it. You must balance it with a prior CFRetain() or CFBridgingRetain() or CFCreate(). Let ARC do what it wants with the id side.
__bridge cast converts id to void* or void* to id with no retain count changes.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
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