我在下面的代碼中面臨崩潰問題(僅在Ad-Hoc構建中)。臨時構建中崩潰問題,同時繪製
- (void)drawPreviewInRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGColorRef strokeColor = [self.delegate.strokeColor CGColor];
CGFloat strokeWidth = self.delegate.strokeWidth;
CGFloat x = rect.size.width/2.0f;
CGFloat y = rect.size.height/2.0f;
CGPoint strokePoint = CGPointMake(x, y);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context, strokeWidth);
CGContextSetStrokeColorWithColor(context, strokeColor);
CGContextMoveToPoint(context, strokePoint.x, strokePoint.y);
CGContextAddLineToPoint(context, strokePoint.x, strokePoint.y);
CGContextStrokePath(context);
CGContextRestoreGState(context);
}
崩潰日誌顯示如下圖:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x10000008
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x39f535b0 objc_msgSend + 16
1 CoreGraphics 0x3237c3ec CGColorRetain + 12
2 CoreGraphics 0x3237c592 CGGStateSetStrokeColor + 38
的代碼在開發環境完全沒有(在兩個模擬器和設備)。任何理論?我正在ARC工作。