2012-01-10 6 views
0

私は逆ジオコーダーを使用しています。私はSQLiteデータベースに情報を保存したいのですが、ユーザーが設定した緯度と経度が必要ですが、渡されません。 私は2つのダブルスは、緯度と経度と呼ばVAR持っていると私は以下のコードを実行すると、それは「ランダム」ダブルス使用しています:目的のCブロックにvarを渡します。

CLLocation *locate = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude]; 

    CLGeocoder *geoCoderCL = [[CLGeocoder alloc] init]; 
    [geoCoderCL reverseGeocodeLocation: locate completionHandler: 
    ^(NSArray *placemarks, NSError *error) { 

     CLPlacemark *placemark = [placemarks objectAtIndex:0]; 

     Controller *mController = [[Controller alloc] init]; 
     MyObject *newposition = [[Meeting alloc]init]; 
     [newposition setLatitude:latitude]; 
     [newposition setLongitude:longitude]; 
     [newposition setMName:[NSString stringWithFormat:@"%@ %@",placemark.thoroughfare,placemark.subThoroughfare]]; 
     NSLog(@"%@ %@",placemark.thoroughfare,placemark.subThoroughfare); 
     [mController createRecentPoint:newposition]; 
     [mController release]; 
     [newposition release]; 

    }]; 

はどのようにこれを行うことになっているの?ありがとう。

答えて

0

CLPlacemarkオブジェクトから緯度と経度を導出するには、以下を使用します。

CLLocationDegrees latitude = placemark.location.coordinate.latitude; 
CLLocationDegrees longitude = placemark.location.coordinate.longitude; 

locationCLLocationオブジェクトです。 coordinateCLLocationCoordinate2D構造体であり、latitudelongitudeCLLocationDegrees(これは単なるtypdef'd doubleです)です。