Iphone 以字符串形式返回用户lat lng

Iphone 以字符串形式返回用户lat lng,iphone,core-location,Iphone,Core Location,有没有一种方法可以从模型中以字符串形式返回用户位置 我有一个模型,它的工作是从web服务下载相同的JSON数据。在发送请求时,我需要在字符串末尾添加?lat=lat_HERE&lng=lng_HERE 我见过大量使用地图或不断更新标签的示例。但我无法找到如何显式返回lat和lng值 iPhone开发才2天,所以请对我放松:)你需要特别利用核心位置。苹果没有提供任何CL编程指南,因此只需查看其中一个示例,就可以了解如何操作。您需要像这样使用CLLocationManager: - (void)vi

有没有一种方法可以从模型中以字符串形式返回用户位置

我有一个模型,它的工作是从web服务下载相同的JSON数据。在发送请求时,我需要在字符串末尾添加?lat=lat_HERE&lng=lng_HERE

我见过大量使用地图或不断更新标签的示例。但我无法找到如何显式返回lat和lng值


iPhone开发才2天,所以请对我放松:)

你需要特别利用核心位置。苹果没有提供任何CL编程指南,因此只需查看其中一个示例,就可以了解如何操作。

您需要像这样使用CLLocationManager:

- (void)viewDidLoad 
    {  
        // this creates the CCLocationManager that will find your current location
        CLLocationManager *locationManager = [[[CLLocationManager alloc] init] autorelease];
        locationManager.delegate = self;
        locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
        [locationManager startUpdatingLocation];
    }

    // this delegate is called when the app successfully finds your current location
    - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
    {
        // retrieve lat and lng in a string from newLocation.coordinate
    NSString *lat = [NSString stringWithFormat:@"%d", newLocation.coordinate.latitude];
    NSString *lng = [NSString stringWithFormat:@"%d", newLocation.coordinate.longitude];
    }

    // this delegate method is called if an error occurs in locating your current location
    - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 
    {
     NSLog(@"locationManager:%@ didFailWithError:%@", manager, error);
    }