我使用全局变量(如下声明)作为纬度和经度,因为我需要在 .h 类的其他类中使用它们:
extern NSNumber *MYGlobalVariableLat;
extern NSNumber *MYGlobalVariableLong;
然后在 .m 类中:
NSNumber *MYGlobalVariableLat;
NSNumber *MYGlobalVariableLong;
MYGlobalVariableLat = [NSNumber numberWithDouble:[(id)self.mapView.userLocation coordinate].latitude];
MYGlobalVariableLong = [NSNumber numberWithDouble:[mapView.userLocation coordinate].longitude];
NSLog(@"Lat %@",MYGlobalVariableLat);
NSLog(@"Long %@",MYGlobalVariableLong);
那总是打印零,请帮助..