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;