How to retrive values of variable defined in one method into other objective c
I have a method
- (void)locationUpdate:(CLLocation *)lo开发者_高级运维cation {
self.locationLatitude = [NSString stringWithFormat:@"%f", location.coordinate.latitude] ;
self.locationLongitude = [NSString stringWithFormat:@"%f", location.coordinate.longitude ];
Now i want to get values of self.locationLatitude and self.locationLongitude into other method of same class But i dont want methodOne to call in locationUpdate:(CLLocation *)location method
-(void)methodOne{
NSLog(%@,Location.Latitude);//it should show coordinate.
}
Other issue is where should i call methodOne? i dont want to call it in locationUpdate method. i want to call it in viewDidLoad method. but when i call it in viewDidLoad nslog shows null
You need to reference the object, using self.
-(void)methodOne{
NSLog(%@, self.locationLongitude);
}
精彩评论