On Oct 30, 2012, at 5:12 PM, Rick Mann <rm...@latencyzero.com> wrote:
> On Oct 30, 2012, at 17:10 , Greg Parker <gpar...@apple.com> wrote:
>> On Oct 30, 2012, at 4:59 PM, Rick Mann <rm...@latencyzero.com> wrote:
>>> On Oct 30, 2012, at 3:15 , Roland King <r...@rols.org> wrote:
>>>> how did you do it before, in non-ARC, what's the code look like? There 
>>>> must be a combination of CFBridgingRetain(), CFBridgingRelease() and 
>>>> (__bridge .. ) you can use to do what you're doing. 
>>> 
>>> Before, I used explicit retain and release. But now, if I 
>>> CFBridgingRetain() my NSObject as I pass it into 
>>> CFSocketCreateConnectedToSocketSignature() (via CFSocketContext), then I 
>>> can't CFBridgingRelease() it in my CFSocketCallBack, it can (will) get 
>>> over-released, because that's called multiple times. So, obviously I can't 
>>> do that.
>> 
>> Where did you use explicit retain and release? Why can you not use the CF 
>> forms in the same places?
> 
> I'm retaining and releasing my own NSObject subclass. Doing so seems to go 
> against the spirit of it all.

> 
> Is it okay to CF-manage an NSObject subclass that's not one of Apple's 
> toll-free bridged classes?

It is. All NS object types are bridged to a generic NSCFType if they aren't 
bridged to something more specific. CFRetain() et al work on all objects. The 
CF functions are the recommended and expected solution for explicit memory 
management in ARC code.

The correct way to write your code is probably 
CFSocketContext ctx;
ctx.retain = CFRetain;
ctx.release = CFRelease;
ctx.info = (__bridge void *)yourObject;


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler



_______________________________________________

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