我有一個解析器類是NSOperation的子類。它用於解析xml,並在解析完成時重新加載表視圖。我有一個刷新的UIBarButtonItem,用來調用解析器並再次從鏈接中解析新的xml。NS操作和重新加載解析器
-(void)refresh {
[self.queue cancelAllOperations]; //cancel all the current operations
[self.queue release];
self.queue=nil;
self.arrayOfAllPhotos = nil; // The array to load table view
[self performSelectorOnMainThread:@selector(doItAgain) withObject:nil waitUntilDone:NO];
}
-(void)doItAgain {
[tableView reloadData];
NSURL *url = [NSURL URLWithString:@"some url"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLConnection *aconnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
self.myConnection = aconnection;
[aconnection release];
}
不過,截至發稿刷新按鈕,應用程序崩潰,沒有消息。我如何釋放NSOperationQueue並再次開始新的分析以加載數據?
比爾,你的意思是2010正確!這是2011年迫在眉睫的.. – petert 2011-06-02 09:25:14