演员加倍?

时间:2011-03-08 13:22:22

标签: objective-c double cllocation

我怎样才能转动或者将某些东西变成双人? CLLocationDegrees实际上是双倍的,所以如何将其转换为double,以便我总是返回双精度,我可以将findAllLocalCountTotal参数更改为double而不是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];

2 个答案:

答案 0 :(得分: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;
}

答案 1 :(得分:0)

这个主题可以帮到你吗? cllocationdegrees