Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS CLLocation属性没有';保留价值_Ios_Iphone_Mkmapview_Xcode5_Cllocation - Fatal编程技术网

iOS CLLocation属性没有';保留价值

iOS CLLocation属性没有';保留价值,ios,iphone,mkmapview,xcode5,cllocation,Ios,Iphone,Mkmapview,Xcode5,Cllocation,我试图在内存中保存CLLocation属性中的self.mapView.userLocation.location,但在我将值分配给属性并检查属性值后,我得到以下结果: +/-0.00m(速度-1.00mps/航程-1.00)@1/19/14 4:21:14 这是我的密码: .h: @属性(保留,非原子)CLLocation*currentlocation 在我的电脑上 - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKU

我试图在内存中保存
CLLocation
属性中的
self.mapView.userLocation.location
,但在我将值分配给属性并检查属性值后,我得到以下结果:

+/-0.00m(速度-1.00mps/航程-1.00)@1/19/14 4:21:14

这是我的密码:

.h:

@属性(保留,非原子)CLLocation*currentlocation

在我的电脑上

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    if (self.currentlocation != self.mapView.userLocation.location)
    {
       self.currentlocation = self.mapView.userLocation.location;
    }

}
我的问题是谁可以在
self.currentlocation
上保留self.mapView.userLocation.location的值并将其保留在内存中


非常感谢您的帮助。

您正在将一个指针分配给另一个指针。因此,实际上您只是存储了对
MKUserLocation
位置的引用

听起来您希望存储当时的值,而不希望它更改。如果是:

 self.currentLocation = [self.mapView.userLocation.location copy];

存储副本应该可以满足您的需要。

您是否已将mapView的
showUserLocation
设置为true?是,self.mapView.showsUserLocation=YEs;