ARC ASIHttpRequest block时出错circle retain的问题及解决方法

来源:互联网 发布:中国历年石油进口数据 编辑:程序博客网 时间:2024/04/29 20:00

在arc开发环境下用ASIHttpRequest,采用block的方式回调http响应时,会出现block will be retained by the captured object的warning.

解决方法是在声明前加__unsafe_unretained


如:

NSURL *url = [NSURL URLWithString:WEB_SERVICE];__unsafe_unretained __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

这样可以同时支持iOS4,因为iOS4不能用__weak.




reference:http://article.ityran.com/archives/1221

原创粉丝点击