I have this method
-(CGContextRef) createPDFContext:(CGRect)inMediaBox path:(CFStringRef) path
{
// bla bla
// at some point I have
CGContextRef myOutContext = CGPDFContextCreate (dataConsumer, &inMediaBox, NULL);
// and then I have to return the value
return myOutContext;
}
The problem is that myOutContext was not released and will leak.
if I put a CGContextRelease (myOutContext) before the return, then the reference will arrive invalid at the caller...
How do I solve that? Doing return [myOutContext autorelease]; will not work, as I suspected and tested.
thanks.