在ARC下,由于使用了Block,在使用ARC后继续获得EXC_BAD_ACCESS. [英] Under ARC, keep getting EXC_BAD_ACCESS after using ARC, because of using Block?

查看:143
本文介绍了在ARC下,由于使用了Block,在使用ARC后继续获得EXC_BAD_ACCESS.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题: 我一直在获取EXC_BAD_ACCESS.在打开NSZombieEnabled之后,我看到了[FeatureCommentListViewController responsesToSelector:]:消息发送到已释放实例0x7c1dc30

Issue: I keep getting EXC_BAD_ACCESS. And after I open NSZombieEnabled, I saw this [FeatureCommentListViewController respondsToSelector:]: message sent to deallocated instance 0x7c1dc30

  1. 在将项目更改为ARC之前,没有此类错误,但是在更改为ARC之后,此错误出现了.

  1. Before I changed my project to ARC, there is no such error, but after I changed to ARC, this error appeared.

我在一个Block中声明一个ViewController并将其推入导航Controller中.请问这种原因会缩短使用寿命吗?

I declare a ViewController in a Block and push it into navigation Controller. Will this reason case it's lifetime shorter?

UIBlockButton来自这篇文章

UIBlockButton is from this post

UIBlockButton *lbGood3 = [[UIBlockButton alloc] initWithFrame:CGRectMake(0, 0, First_Button_Width, [self getGoodRow2Height:productDetail]) ];
[lbGood3 handleControlEvent:UIControlEventTouchUpInside withBlock:^ { 
NSLog(@"%@", Label.text); 

ProductDetail *productDetail = [productDetailDict objectForKey:@"product"];
NSString *dp_id = [NSString stringWithFormat:@"%@-%@",productDetail.url_crc,productDetail.site_id];


FeatureCommentListViewController *cmtListController = [[FeatureCommentListViewController alloc] initWithNibName:@"FeatureCommentListViewController" bundle:nil];
cmtListController.title = Label.text;
cmtListController.isReviewed=isReviewed;
cmtListController.productDetail=productDetail;
cmtListController.dp_id=dp_id;
cmtListController.feature_name = @"&feature_good_id=2";

[self.navigationController pushViewController:cmtListController animated:YES];

}];

我应该将控制器声明为该viewController的成员,还是只声明该块之外?

Should I declare the controller as a member of this viewController or just declare out of the block?

推荐答案

我通过在viewDidLoad函数中分配FeatureCommentListViewController并在块中使用它来解决此问题.

I solved this by alloc the FeatureCommentListViewController in the viewDidLoad function and use it in block.

这篇关于在ARC下,由于使用了Block,在使用ARC后继续获得EXC_BAD_ACCESS.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆