Reputation: 10759
How can I turn or maybe cast something to a double? CLLocationDegrees is really a double so how do I cast it as double so my if always returns doubles and I can change my findAllLocalCountTotal params to double instead of 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];
Upvotes: 1
Views: 5931
Reputation: 53000
Just use a cast and also move the variable declaration outside of the if
- the if
& else
branches are distinct scopes and introduced their own variables:
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;
}
Upvotes: 4