On Jun 19, 2012, at 8:28 PM, Dave Keck <[email protected]> wrote:
> I have a CFType (specifically a CGPattern) that uses a release
> callback to free resources, and the void* pointer passed to the
> callback is the object to be released.
>
> What's the correct way to release this void* pointer (that's really an
> NSObject subclass) under ARC? Casting it using __bridge_transfer
> doesn't seem right since the resulting expression is unused, and the
> compiler of course warns of this fact.
The right way to handle void* context parameters in ARC is usually one of these:
For one-shot contexts:
Set the void* context with CFBridgingRetain(object).
Retrieve your object with (ObjectType *)CFBridgingRelease(context).
For persistent contexts:
Set the void* context with CFBridgingRetain(object).
Retrieve your object with (__bridge ObjectType *)context.
Clean up the void* context with CFRelease(context) or (ObjectType
*)CFBridgingRelease(context)
In C++ you'll need extra casts between void* and CFTypeRef.
If you're talking about the void* info parameter to CGPatternCreate, use the
"persistent context" code.
--
Greg Parker [email protected] Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [email protected]