当我分析我的项目但项目没有崩溃时,我收到了死存储警告。 这是我正在做的
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;
编辑:
您还应该更改使用它的行:
aURL = [aValue copy];
关于ios - Xcode 中的 "Dead Store"警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7597679/