Error EXC_ARM_DA_ALIGN when working on the device

Why does this code work on a simulator and crash on a real device?

I have a very simple code that draws a circle. Subclasses of code UIViewwork fine on Simulator (both for iOS 5.1 and iOS 6.0).

Circle.h

#import <UIKit/UIKit.h>

@interface Circle : UIView

@end

Circle.m

#import "Circle.h"

@implementation Circle

-(CGPathRef) circlePath{
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path addArcWithCenter:self.center radius:10.0 startAngle:0.0 endAngle:360.0 clockwise:YES];
    return path.CGPath;
}

- (void)drawRect:(CGRect)rect
{
    CGPathRef circle = [self circlePath];

    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextAddPath( ctx, circle );
    CGContextStrokePath(ctx);
}

@end

When I try to execute code on iPad2 running iOS 5.1.1, I get an error ( EXC_BAD_ACCESS(code=EXC_ARM_DA_ALIGN,address=0x31459241)) in the line CGContextAddPath( ctx, circle );.

I do not know what the problem is. Can someone point me in the right direction to solve this problem?

+1
source share
1 answer

, CGPath UIBezierPath, circlePath. , , UIBezierPath , . , UIBezierPath:

-(UIBezierPath *)circlePath {
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path addArcWithCenter:self.center radius:10.0 startAngle:0.0 endAngle:360.0 clockwise:YES];
    return path;
}

, :

CGContextAddPath( ctx, circle.CGPath );
0

All Articles