I am uncertain as when to release the path created by CGPathCreateMutable in the code sample below.
// iVar
ivarImageView = [[UIImageView alloc] initWithImage:nil];
// Clip to shape
CALayer *imageLayer = [self.ivarImageView layer];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
CGMutablePathRef clipPath = CGPathCreateMutable();
shapeLayer.path = clipPath;
imageLayer.mask = shapeLayer;
[self addSubview:self.ivarImageView];
iVarImageView is an ivar that is retained. So it is in use for the life of the object, as is its shapLayer.path. So when is the proper time to release this path?
You can release it after the line:
shapeLayer.path = clipPath;
Since you are assigning to shapeLayer.path
, you dont have to worry about the clipPath
after that as it will be owned by shapeLayer
.