経度と緯度を 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)
それを返す手がかりはありますか?