线程是否会干扰程序的正常工作行为?
|
我有一个视图控制器,它是UIViewController的子类,该类具有表视图,并且表视图中的每一行都链接到不同的xml url。我制作了一个解析器类,它是NSOperation的子类,并实现了一些方法,可以在选择每行时将XML文件解析为:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self performSelectorOnMainThread:@selector(pushView) withObject:nil waitUntilDone:NO];
[self performSelectorInBackground:@selector(parseOperation:) withObject:indexPath];
}
-(void)pushView{
detailView = [[viewDetailsController alloc] initWithNibName:@\"viewDetailsController\" bundle:nil];
[self.navigationController pushViewController:detailView animated:YES];
}
-(void)parseOperation:(NSIndexPath *)indexPath{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
self.queue = [[NSOperationQueue alloc] init];
parserClass *parser = [[parserClass alloc] initWithParseUrl:[[self.arrayOfUrls objectAtIndex:indexPath.row]delegate:self];
[queue addOperation:parser];
[parser release];
[pool release];
}
解析器工作得很好,但是在我调用的自定义委托方法中,将视图控制器推入导航控制器堆栈的顶部,该视图控制器正确初始化,但新的视图控制器未推入屏幕。
我不知道为什么这不起作用。
没有找到相关结果
已邀请:
2 个回复
磐去裸猜饲
暑袜眠退
或者,您可以直接调用tableView的方法: