下面的代码工作正常,我只是不知道发布应该去哪里,因为我不确定规则是什么。我没有使用ARC。
- (void)myFunc {
// stuff happens
__block UIImage* photo = [UIImage imageWithCGImage:croppedCGImage];
[photo retain];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
(unsigned long)NULL), ^(void) {
[self doStuffToPhoto:photo];
// [photo release] causes EXC_BAD_ACCESS
});
// [photo release] causes EXC_BAD_ACCESS in doStuffToPhoto
}
- (void)doStuffToPhoto:(UIImage*)photo {
// do stuff
// [photo release] causes EXC_BAD_ACCESS
}