0
我想我在某處丟失了一些明顯的東西。 我有一個(CLLocation *)lastqueriedlocation在標題中定義爲一個屬性和綜合。我想在的LocationManager更新它:didUPdateToLocation:fromLocation:保存一個持久的CLLocation
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{ CLLocationDistance dist = [lastQueriedLocation getDistanceFrom:newLocation]; if (dist>1000) { lastQueriedLocation = newLocation; [self reSearch:lastQueriedLocation]; } if ([resultArray count] > 0) { [self findAndDisplayNearestLocation:location]; } }
lastQueriedLocation被alloced和viewDidLoad中init'd。
問題是當然lastQueriedLocation = newLocation;
結果在EXC_BAD_ACCESS
。那麼堅持lastQueriedLocation的正確方法是什麼?
如果它有助於使問題更具體 - reSearch正在調用一個Web服務在位置2公里內獲取POI - 所以我只想在移動1km時執行此操作...但我仍然希望保持準確性最好,所以我可以突出最近的,滾動地圖等。