Cocoa touch 更改位置的坐标

Cocoa touch 更改位置的坐标,cocoa-touch,Cocoa Touch,我不熟悉目标C,所以这可能是一个微不足道的问题: 初始化位置后: CLLocation *currentPoint = [[CLLocation alloc] initWithLatitude:0 longitude:0]: 以后如何更改纬度和经度 CLLocation对象是不可变的(您不能更改它们)。根据文件: 通常,使用CLLocationManager对象根据用户设备的最后一个已知位置创建此类的实例。但是,如果要缓存自定义位置数据或获取两个不同坐标点之间的距离,可以自己创建实例 下面是一

我不熟悉目标C,所以这可能是一个微不足道的问题:

初始化位置后:

CLLocation *currentPoint = [[CLLocation alloc] initWithLatitude:0 longitude:0]:

以后如何更改纬度和经度

CLLocation
对象是不可变的(您不能更改它们)。根据文件:

通常,使用CLLocationManager对象根据用户设备的最后一个已知位置创建此类的实例。但是,如果要缓存自定义位置数据或获取两个不同坐标点之间的距离,可以自己创建实例


下面是一个如何修改CLLocation的示例:

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation{


    newLocation = [[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(newLocation.coordinate.latitude, -1.1874988592864875)
                                                 altitude:newLocation.altitude
                                       horizontalAccuracy:newLocation.horizontalAccuracy
                                         verticalAccuracy:newLocation.verticalAccuracy
                                            timestamp:newLocation.timestamp] autorelease];
下面是另一个如何创建新CLLotation的示例:

CLLocation *newLocation = [[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(41.44994138650804, -1.1874988592864875)
                                                   altitude:0
                                         horizontalAccuracy:0
                                           verticalAccuracy:0
                                                  timestamp:[NSDate date]] autorelease];

谢谢,所以我将使用变量来存储位置并使其可更改。