Value Stored to during its initialization is never read
float latitude = [((IPADAppDelegate *)[UIApplication sharedApplication].delegate).detailViewController.userStoreInfoObj.StoreLatitude floatValue];
float longitude = [((IPADAppDelegate *)[UIApplication sharedApplication].delegate).detailViewController.userStoreInfoObj.StoreLongitude floatValue];
NSString *strAddress = [((IPADAppDelegate *)[UIApplication sharedApplication].delegate).detailViewController.userStoreInfoObj StoreAddress];
NSString *strCountry= [((IPADAppDelegate *)[UIApplication sharedApplication].delegate).detailViewController.userStoreInfoObj StoreCounty];
NSString *strCode = [((IPADAppDelegate *)[UIApplication sharedApplication].delegate).detailViewController.userStoreInfoObj StoreZip];
if(storeData)
{
latitude 开发者_高级运维= [storeInfoObj.StoreLatitude floatValue];
longitude = [storeInfoObj.StoreLongitude floatValue];
strAddress = [storeInfoObj StoreAddress];
strCountry = [storeInfoObj StoreCounty];
strCode = [storeInfoObj StoreZip];
}
Value stored to latitude during its initialization is never read.
Can anyone help me understand why this is happening?
What can I do to fix this? Please help me out [I try my luck].
@ Thanks in advance
one example: the static analyzer has likely detected that storeData
will always evaluate to true:
StoreData * storeData = thing.storeData;
if (!storeData) {
/* get out of here!!! */
return;
}
IPADAppDelegate * appDelegate = (IPADAppDelegate*)[UIApplication sharedApplication].delegate;
UserStoreInfoObj * userStoreInfoObj = appDelegate.detailViewController.userStoreInfoObj;
float latitude = [userStoreInfoObj.StoreLatitude floatValue];
float longitude = [userStoreInfoObj.StoreLongitude floatValue];
NSString *strAddress = [userStoreInfoObj StoreAddress];
NSString *strCountry= [userStoreInfoObj StoreCounty];
NSString *strCode = [userStoreInfoObj StoreZip];
if (storeData) << would be redundant and always true
{
latitude = [storeInfoObj.StoreLatitude floatValue]; << why not initialize latitude using this value???
longitude = [storeInfoObj.StoreLongitude floatValue];
strAddress = [storeInfoObj StoreAddress];
strCountry = [storeInfoObj StoreCounty];
strCode = [storeInfoObj StoreZip];
}
but you can significantly reduce the complexity of this program (to read, maintain, and execute) by using something like this:
UserStoreInfoObj * storeInfo = nil;
if (storeData) storeInfo = storeInfoObj;
else storeInfo = ((IPADAppDelegate *)[UIApplication sharedApplication].delegate).detailViewController.userStoreInfoObj;
float latitude = [storeInfo.StoreLatitude floatValue];
float longitude = [storeInfo.StoreLongitude floatValue];
NSString *strAddress = [storeInfo StoreAddress];
NSString *strCountry= [storeInfo StoreCounty];
NSString *strCode = [storeInfo StoreZip];
精彩评论