我使用全局变量(声明如下)来获取纬度和经度,因为我需要在其他类中使用它们 在.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);
总是打印零,请帮忙..