2010-05-28 48 views
0

這是一個奇怪的,你們都。設置核心位置結果爲NSNumber對象參數

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{ 

    CLLocationCoordinate2D coordinate = newLocation.coordinate; 
    self.mark.longitude = [NSNumber numberWithDouble:coordinate.longitude]; 
    self.mark.latitude = [NSNumber numberWithDouble:coordinate.latitude]; 
    NSLog(@"Got %f %f, set %f %f", coordinate.latitude, coordinate.longitude, self.mark.latitude, self.mark.longitude); 

    [manager stopUpdatingLocation]; 
    manager.delegate = nil; 

    if (self.waitingForLocation) { 
     [self completeUpload]; 
    } 
} 

latitudelongitude在 「標記」 對象被合成參照的NSNumber IVARS參數。

在模擬器,我的NSLog輸出,中間這條線就有記載:

2010-05-28 15:08:46.938 EverWondr[8375:207] Got 37.331689 -122.030731, set 0.000000 -44213283338325225829852024986561881455984640.000000 

這一大堆比1無限循環再東!設備上的數字是不同的,但類似的lat仍然是零,long是非常不可能的高負數。

在亞洲其他控制器我接受按下按鈕並上傳其地理編碼信息相關的文件(圖像我只是把相機附帶),我需要的是self.waitingForLocation通知CLLocationManager委託,我已經打的按鈕,一旦它完成了它的交易,它應該繼續並啓動上傳。事情是,在向上按鈕,點擊接收方法,我測試看看是否CL通過測試self.mark.latitude,這似乎是越來越設置爲零完成...

回答

2

要打印的指針指向NSNumber對象作爲float小號 - 這可能看起來完全不同。

用途:

NSLog(@"Got %f %f, set %@ %@", coordinate.latitude, coordinate.longitude, 
     self.mark.latitude, self.mark.longitude); 

...或:

NSLog(@"Got %f %f, set %f %f", coordinate.latitude, coordinate.longitude, 
     [self.mark.latitude doubleValue], [self.mark.longitude doubleValue]); 
+0

這顯然是星期五下午。謝謝。 – 2010-05-28 20:03:44