【发布时间】:2013-04-28 18:48:07
【问题描述】:
我正在尝试将经度和纬度转换为 NSNumbers 以将它们保存在核心数据中。
按照我的代码:
获取坐标
CLLocationCoordinate2D coordinate = [[mapView.annotations objectAtIndex:0] coordinate];
NSLog(@"Long2: %f", coordinate.longitude);
NSLog(@"Lat2: %f", coordinate.latitude);
输出
2013-04-28 20:22:05.918 [1892:16a03] Long2: -122.406417
2013-04-28 20:22:05.918 [1892:16a03] Lat2: 37.785834
设定值:
[members.eventDTO setLatLong:coordinate];
- (void)setLatLong: (CLLocationCoordinate2D)coordinate{
self.locLatitude = [NSNumber numberWithDouble:coordinate.latitude];
self.locLongitude = [NSNumber numberWithDouble:coordinate.longitude];
}
然后我尝试了输出:
NSLog(@"Long2: %f", [members.eventDTO.locLongitude doubleValue]);
NSLog(@"Lat2: %@", members.eventDTO.locLatitude);
2013-04-28 20:22:05.918 [1892:16a03] Long2: 0.000000
2013-04-28 20:22:05.919 [1892:16a03] Lat2: (null)
任何线索它返回?
【问题讨论】:
标签: iphone objective-c xcode cllocationmanager nsnumber