开发者

How to retrive values of variable defined in one method into other objective c

开发者 https://www.devze.com 2023-04-04 18:43 出处:网络
I have a method - (void)locationUpdate:(CLLocation *)lo开发者_高级运维cation { self.locationLatitude = [NSString stringWithFormat:@\"%f\", location.coordinate.latitude] ;

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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号