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];
}
永远不会读取在初始化期间存储到纬度的值。
任何人都可以帮助我理解为什么会这样吗?
我该怎么做才能解决这个问题?请帮帮我[我试试运气]。
@提前致谢
答案 0 :(得分:0)
一个例子:静态分析器可能检测到storeData
总是评估为真:
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];
}
但是你可以通过这样的方式显着降低这个程序的复杂性(读取,维护和执行):
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];