Could someone please explain why I get the “potential leak of an object” warning here ? I don’t get it. Thank you!
-(Code) drawTo:(ContextClass *) trg
{
CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB();
CGFloat values[4] = { getRed(colour),
getGreen(colour),
getBlue(colour), 1.0 };
trg.storedColourRef = CGColorCreate(rgbColorspace, values);
CGColorSpaceRelease(rgbColorspace);
return OK;
}
Is it because I store the object in trg.storedColourRef ? … which is a property in a different class:
@property (nonatomic, assign) CGColorRef storedColourRef;
Yes, that’s because you create Quartz color with
CGColorCreate()and pass it to some external (?) object. Compiler could not find correspondingCGColorRelease()call that shall be used to destroy color object and therefore generates this warning.