gpt4 book ai didi

iphone - 找不到我的iPhone的经度和纬度

转载 作者:行者123 更新时间:2023-12-01 17:57:39 25 4
gpt4 key购买 nike

我试图找出iphone的当前位置,为此,我正在使用这种方法。并尝试将其保存以备进一步使用。但是当我以经度和纬度的形式打印位置值时,它总是给我0.00000和0.0000。我并没有指出我错了。此方法保存在GetLocation类中。

-(void)updatelocation{

NSLog(@"coming in update location in get location class");
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];

NSLog(@"location manager %@", locationManager);
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
NSString *latitude = [NSString stringWithFormat:@"%f", coordinate.latitude];
NSString *longitude = [NSString stringWithFormat:@"%f", coordinate.longitude];

NSLog(@"Latitude is: %f\n\n\n and longitude is: %f\n\n\n", location.coordinate.latitude, location.coordinate.longitude);
NSLog(@"coordinate %f",coordinate.latitude);
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
[defaults setObject:latitude forKey:@"latitude"];
[defaults setObject:longitude forKey:@"longitude"];

}

当我在另一个这样的类中调用此方法时。
GetLocation *location = [GetLocation alloc] init ];
[location updatelocation];

但我总是得到0.0000和0.0000。谁能告诉我我错了。

最佳答案

关于iphone - 找不到我的iPhone的经度和纬度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14495292/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com