Unclear about releasing CFDictionaryRef

automatic-ref-counting, cocoa, core-foundation, ios

Solution

Use `CFBridgingRelease` to transfer the ownership into ARC

CFDictionaryRef cfDict = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL);
NSDictionary *dict = (NSDictionary *)CFBridgingRelease(cfDict);

Otherwise you would need to call `CFRelease` when you have finished with the dictionary.

Problem

I'm unclear about the memory management implications of the following: ``` NSDictionary* props = (__bridge NSDictionary*) CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); ``` Since the `CGImageSourceCopyPropertiesAtIndex` function has Copy in the name, I own the CFDictionaryRef and must release it. However, since it's cast to an `NSDictionary`, I can't call `[props release]`. What's the proper way to treat this?

Original source