1

我怎样才能把东西转或投到一个替身?CLLocationDegrees 真的是双精度,所以我如何将它转换为双精度,这样我的 if 总是返回双精度,我可以将 findAllLocalCountTotal 参数更改为双精度而不是 CLLocationDegrees?

if(self.lastKnownLocation == nil ){
    double lat = [CLController sharedInstance].latitude;
    double lng = [CLController sharedInstance].longitude;

}else{
    CLLocationDegrees lat = self.lastKnownLocation.coordinate.latitude;
    CLLocationDegrees lng = self.lastKnownLocation.coordinate.longitude;
}

NSNumber *tempInt = self.lastPostsGrabbedCounter;



//Make call to get data with lat lng
self.webServiceAllCount = [Post findAllLocalCountTotal:(CLLocationDegrees)lat withLong:(CLLocationDegrees)lng];
4

2 回答 2

4

只需使用强制转换并将变量声明移出if- if&else分支是不同的范围并引入了它们自己的变量:

double lat, lng;
if(self.lastKnownLocation == nil)
{
   lat = [CLController sharedInstance].latitude;
   lng = [CLController sharedInstance].longitude;
}
else
{
   lat = (double)self.lastKnownLocation.coordinate.latitude;
   lng = (double)self.lastKnownLocation.coordinate.longitude;
}
于 2011-03-08T18:04:43.587 回答
0

这个话题能帮到你吗?配置度

于 2011-03-08T13:27:16.967 回答