Crash using [UIBezierPath CGPath] with CAShapeLayer under ARC

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];// CRASHES
morph.toValue =  CFBridgingRelease([[self makeToPath] CGPath]);// CRASHES

-(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;
}
+5
2

CGPath. - CGPathRef, ARC. UIBezierPath . , CGPathRef. , ARC :

.h:

-(CGPathRef)makeToPath CF_RETURNS_RETAINED;
-(CGPathRef)makeFromPath CF_RETURNS_RETAINED;
+8

, CGPath, UIBezierPath, . UIBezierPath CGPath:

UIBezierPath , .

CGPath :

-(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];
    CGPathRef theCGPath = [triangle CGPath];
    return CGPathCreateCopy(theCGPath);
}

llvm, , cf_returns_retained , .

, , cf_returns_retained . . ( .)

, , :

-(CGPathRef)makeToPath CF_RETURNS_RETAINED;
{
    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];
    CGPathRef theCGPath = [triangle CGPath];
    return CGPathCreateCopy(theCGPath);
}
+3

All Articles