我有一个方法
- (void)locationUpdate:(CLLocation *)location {
self.locationLatitude = [NSString stringWithFormat:@"%f", location.coordinate.latitude] ;
self.locationLongitude = [NSString stringWithFormat:@"%f", location.coordinate.longitude ];
现在我想将self.locationLatitude和self.locationLongitude的值转换为同一类的其他方法但我不希望methodOne在locationUpdate中调用:(CLLocation *)location method
-(void)methodOne{
NSLog(%@,Location.Latitude);//it should show coordinate.
}
其他问题是我应该在哪里调用methodOne?我不想在locationUpdate方法中调用它。我想在viewDidLoad方法中调用它。但是当我在viewDidLoad中调用它时,nslog显示为null
答案 0 :(得分:1)
您需要使用self来引用该对象。
-(void)methodOne{
NSLog(%@, self.locationLongitude);
}