In my UIView, I have a couple of CGPath's stored in a NSArray (availablePaths).
Before anything is drawn, I create a scaled version of each CGPath and replace the old one in the array.
I get a SIGABRT in drawRect using the following code.
- (void) scaleAllPaths: (CGFloat) scaleFactor
{
CGAffineTransform transform = CGAffineTransformMakeScale(scaleFactor, scaleFactor);
CFIndex i;
for(i=0;i<[availablePaths count];i++){
id obj = [availablePaths objectAtIndex:i];
CGPathRef oldPath = (CGPathRef)obj;
CGMutablePathRef newPath = CGPathCreateMutable();
CGPathAddPath(newPath, &transform, oldPath);
[availablePaths replaceObjectAtIndex:i withObject:(id) newPath];
CGPathRelease(newPath); // <--- causes SIGABRT in drawRect:
}
}
-(void)drawRect:(CGRect)rect
{
...
for (int i = 0; i < currentPathIndex; i++) {
id obj = [availablePaths objectAtIndex:i];
CGPathRef path = (CGPathRef)obj;
CGContextBeginPath(context);
CGContextAddPath(context, path); // <--- SIGABRT
CGContextDrawPath(context, kCGPathEOFill);
}
...
Without the CGPathRelease(newPath) drawing works fine, but of course, I'm getting the memory leak.