I get a BAD ACCESS error using [UIBezierPath CGPath]c CAShapeLayerin ARC. I tried bridges in many ways, but I don’t understand that this is a problem. I highlighted the collapse to use the result of the method makeToPath:
maskLayer = [CAShapeLayer layer];
maskLayer.path = [self makeToPath];
But this is not a failure:
maskLayer = [CAShapeLayer layer];
maskLayer.path = [self makeFromPath];
Is there something invalid with the path created makeToPath? I plan to use the from and to paths with help CABasicAnimationafter sorting this failure. What is the correct ARC bridge connection for CGPathReffrom UIBezierPath?
-(CGPathRef)makeToPath
{
UIBezierPath* triangle = [UIBezierPath bezierPath];
[triangle moveToPoint:CGPointZero];
[triangle addLineToPoint:CGPointMake(self.view.frame.size.width,0)];
[triangle addLineToPoint:CGPointMake(0, self.view.frame.size.height)];
[triangle closePath];
return [triangle CGPath];
}
-(CGPathRef)makeFromPath
{
UIBezierPath*rect = [UIBezierPath bezierPathWithRect:self.view.frame];
return [rect CGPath];
}
UPDATE So, I changed my .h file to one of the answers below, but I still get the error message
-(CGPathRef)makeToPath CF_RETURNS_RETAINED;
-(CGPathRef)makeFromPath CF_RETURNS_RETAINED;
UIBezierPath ( ). . - , ?
maskLayer.path = [[self makeToPath] CGPath];
morph.toValue = CFBridgingRelease([[self makeToPath] CGPath]);
-(UIBezierPath*)makeToPath
{
UIBezierPath* triangle = [UIBezierPath bezierPath];
[triangle moveToPoint:CGPointZero];
[triangle addLineToPoint:CGPointMake(self.view.frame.size.width,0)];
[triangle addLineToPoint:CGPointMake(0, self.view.frame.size.height)];
[triangle closePath];
return triangle;
}