On 31 Aug 2010, at 17:02, Roland King wrote:

> can you do this? 
> 
>       CFMutableDictionaryRef tokenByParent = CFDictionaryCreateMutable( NULL, 
> 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks );
>       [ (NSMutableDictionary*)tokenByParent autorelease ];
> 
> with of course the desire to continue using tokenByParent in the routine. 
> 
> CFMutableDictionaryRef is toll-free bridged with NSMutableDictionary but does 
> that that extend to autoreleasing it? 
> 
> Normally I balance alloc/init with release and CF..Create.. with CFRelease(), 
> in this case I have deeply nested code iterating over a database and there 
> are multiple ways it can fail, I'm testing for the failures and returning 
> appropriate errors but don't want to have to deal with figuring out what I 
> need to release at 10 different exit points to the routine so I'd like to 
> just use autorelease and let someone else worry about it. The alternative is 
> either massive nested if() code or abusing @try/@finally with no @catch to 
> release everything on the way out the door. 
> 
> Is it ok to cast a CF object to an NS object for the purpose of autoreleasing 
> it? 

Yes, provided you are not writing dual-mode GC/manual memory management code. 
The Static Analyzer will do a good job warning you of this anyhow.

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to