这就是我实现我的方式。Sometihng 只是不正确
-(void)setCurrentAnchor:(CLLocation *)currentAnchor
{
//CM(@"set current anchor");
/*@synchronized (self)
{
}*/
if (_currentAnchor==currentAnchor)
{
return;
}
//[Tools DoSomethingWithSynchronize:^{
@synchronized(self){
_currentAnchor=currentAnchor;
[Timer searchCriteriaChanged];
[cachedProperties setDistanceForAllBiz];
}
//}];
}
-(CLLocation *)currentAnchor
{
//[Tools DoSomethingWithSynchronize:^{
//}];
@synchronized(self){
} //Empty @synchronized section just to block every other thread
[self setCurrentLocationasAnchorifNil];
return _currentAnchor;
}
目标当然是确保 currentAnchor 在更改时永远不会被访问。我这样做对吗?