ユーザーが地図ビューを変更するたびに、(Zillow アプリのように) ピンをドロップしたいという点で、私は地図アプリケーションに取り組んでいます。次のコードコードを使用しています。NSAutoreleasepool を使用してサーバーから xml データをロードし、バックグラウンド スレッドで xml 解析を実行しようとしています。
(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{
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];
}
-(void)callParsing{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[self parseXMLFileAtURL:urlString];
[self performSelectorOnMainThread:@selector(droppingPin) withObject:nil waitUntilDone:YES];
[pool drain];
}
上記のコードは正常に動作していますが、マップビューを変更すると、アプリケーションがクラッシュします。誰でも問題を解決するのを手伝ってくれますか?
前もって感謝します。