【发布时间】:2011-11-04 12:42:41
【问题描述】:
在启用 ARC 的代码中,如何在使用基于块的 API 时修复有关潜在保留周期的警告?
警告:Capturing 'request' strongly in this block is likely to lead to a retain cycle
由此产生的sn-p代码:
ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:...
[request setCompletionBlock:^{
NSDictionary *jsonDictionary = [[CJSONDeserializer deserializer] deserialize:request.rawResponseData error:nil];
// ...
}];
警告与块内对象request的使用有关。
【问题讨论】:
-
您可能应该使用
responseData而不是rawResponseData,请查看ASIHTTPRequest 文档。
标签: cocoa-touch cocoa asihttprequest automatic-ref-counting retain