【发布时间】:2012-11-05 10:49:31
【问题描述】:
我正在使用以下代码并且正在使用 ARC
NSString *text;
static NSString *CellIdentifier=@"Cell";
FeedsCell *cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[FeedsCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
if (indexPath.row == [feedsData count]-1)
{
[spinner startAnimating];
[spinner setHidesWhenStopped:YES];
OnDemand_fetch *getData = [[OnDemand_fetch alloc] init];
if(nextUrl != NULL)
{
NSString *nextfbUrl = [getData getnextFbfeedUrl];
NSString *nexturlEdited = [nextfbUrl stringByReplacingOccurrencesOfString:@"|" withString:@"%7C"];
[demandfetch getFeedsInBackground:nexturlEdited];
}
else
{
[spinner stopAnimating];
self.myTableView.tableFooterView=nil;
}
在分析时,显示警告: “在第 267 行分配并存储到 'getData' 中的对象的潜在泄漏。”
谁能建议避免这种情况的方法?这会造成什么麻烦吗?
谢谢
【问题讨论】:
-
你确定是 ARC 吗?这对我来说看起来不错。
getData是否在其他地方使用过? -
是的..我确定,我不会在其他任何地方使用 getData 对象。
-
将
OnDemand_fetch *getData = [[OnDemand_fetch alloc] init];更改为OnDemand_fetch *getData = [[[OnDemand_fetch alloc] init] autorelease];。这会在构建时带来任何错误吗? -
没有错误!但我正在使用 ARC!为什么会有这种奇怪的行为?
-
如果编译器允许你使用
autorelease,那么你就没有使用ARC。 ARC 禁止调用 autorelease。