2010-05-28 50 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