16

有一个带有三个变量纬度(NSNumber),经度(NSNumber)和时间(NSDate)的坐标对象,用于检查我的模拟器上的程序,我给出了以下代码

[coordinate setLatitude:[NSNumber numberWithDouble:23.234223]];
[coordinate setLongitude:[NSNumber numberWithDouble:73.234323]];

但是,当我 NSLog 坐标.纬度和坐标.经度时,它显示 0.00000

NSLog(@"cordlat :  %f",coordinate.latitude);
NSLog(@"cordlong :  %f",coordinate.longitude);

可能是什么问题???

4

1 回答 1

9

您无法打印NSNumberwith %f。您可以执行以下操作之一:

  1. NSLog(@"cordlat : %@", coordinate.latitude);
  2. NSLog(@"cordlat : %f", coordinate.latitude.doubleValue);
于 2010-11-24T11:39:23.773 回答