Using Arc, I have a CgImageRef as a property of an object (Shape). Ultimately I will assign the CgImageRef to the contents of 1 or more layers but initially I just keep it in the shape. Things work fine if I do this:
CgImageRef cgImageRef = CGImageCreateWithImageInRect(....);
someLayer.contents = (__bridge id)cgImageRef;
CFRelease(cgImageRef);
but if I say
myShape.cgImageRef = CGImageCreateWithImageInRect(...);
the analyzer reports a potential memory leak.
I tried, within the ShapeObject, adding a dealloc method that uses CFRelease on the cgImageRef, but then the analyzer says that I am releasing an object I do not own.
Bridging does not seem to apply since I'm not assigning the pointer to another object. What exactly am I supposed to do here?