1

どうすればダブルに何かを回したりキャストしたりできますか? CLLocationDegrees は実際には double です。それを double としてキャストして、常に double を返すようにするにはどうすればよいですか?

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 に答える