0
我正在處理地圖應用程序,因爲我希望在用戶更改地圖視圖時放棄引腳(如在Zillow應用程序中)。我正在使用下面的代碼。我嘗試使用NSAutoreleasepool從服務器加載xml數據在後臺線程中執行xml解析。在MKMapview中使用NSAutoreleasepool時應用程序崩潰regionDidChangeAnimated方法
(無效)的MapView:(的MKMapView *)的MapView regionDidChangeAnimated:(BOOL)動畫{
的NSLog(@ 「內部區域沒有改變」);
urlString =[NSString stringWithFormat: @"http://asdfasdasdf.com/asdfasdf/mapxml.php]; [stories1 release]; [mapview removeAnnotations:eventPoints1]; eventPoints1 = [[NSMutableArray array] retain]; [self performSelectorInBackground:@selector(callParsing) withObject:nil];
}
- (無效)callParsing {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[self parseXMLFileAtURL:urlString];
[self performSelectorOnMainThread:@selector(droppingPin) withObject:nil waitUntilDone:YES];
[pool drain];
}
上面的代碼工作正常,但一旦我改變的MapView,所述appllication得到墜毀。任何人都可以幫我解決這個問題?
在此先感謝。