【发布时间】:2015-07-15 14:22:01
【问题描述】:
我有以下类构造函数
- (id)initForBlurringWithConstantMaskWithID:(int)maskid andSize:(CGSize)s{
self = [super init];
if (self) {
// some code
CGImageRef maskRef = [maskUI CGImage];
//Some code where maskRef is used
CGImageRelease(maskRef); // I won't ever use it again
}
return self;
}
但是,当使用 ARC(在我看来)释放对象时,一切都会因 EXC_BAD_ACCESS(代码=EXC_i386_GPFLT)而崩溃,这通常在访问“错误”地址时调用。
如果我删除发布行,一切正常。无论如何,谁能解释为什么会这样?
我的猜测是 ARC 也在尝试删除 maskRef,但找不到它并导致崩溃。
【问题讨论】:
标签: objective-c constructor crash automatic-ref-counting release