【发布时间】:2011-11-27 16:49:31
【问题描述】:
当我分析我的项目但项目没有崩溃时,我收到了死店警告。 这就是我正在做的事情
NSString *graphUrl = nil;
if ([graphArray count] == 1)
{
objTrial = [graphArray objectAtIndex:0];
graphUrl = @"http://chart.apis.google.com/chart?cht=s:nda&chf=bg,s,FFFFFF&chs=";
graphUrl = [graphUrl stringByAppendingString:@"&chd=t:"];
graphUrl = [graphUrl stringByAppendingString:objTrial.highValue];// get the dead store error here
}
else
{
//someother operation is done and a value is loaded to aURL
}
我收到代码中提到的死店警告。如何防止这种情况发生?
如果有人能在这方面帮助我,那就太好了
【问题讨论】:
-
大概你的意思是
NSString *aUrl = @"";在第一行? -
如果给一个局部变量赋值,但后面的任何指令都没有读取到这个值,则称为死存储。死存储会浪费处理器时间和内存。所以只需使用变量,警告就会消失。
标签: ios xcode memory-management nsstring