我是IOS新手我需要在我的程序中實現NSThread,但是當它調用它時會顯示SIGABRT錯誤。我當前的代碼下面給出NSThread顯示SIGABRT
XMLParser.m
-(void)loadXML
{
categories =[[NSMutableArray alloc]init];
NSString *filepath =[[NSBundle mainBundle]pathForResource:@"cd_catalog" ofType:@"xml"];
NSData *data =[NSData dataWithContentsOfFile:filepath];
parser=[[NSXMLParser alloc]initWithData:data];
parser.delegate =self;
[parser parse];
}
ViewController.m
- (void)viewDidLoad
{
xmlParser =[[XMLParser alloc]init];
NSThread *myThread =[[NSThread alloc]initWithTarget:self selector:@selector(loadXML) object:nil];
[myThread start];
[super viewDidLoad];
}
請告訴我什麼是錯我的程序
您是否使用ARC哪裏是你的應用程序後'的'裏面viewDidLoad' – 2013-03-18 05:22:09
viewDidLoad'崩潰是我使用ARC和它的崩潰,當它到達nsthread實施 – Optimus 2013-03-18 05:26:59
這可能是由於運行循環。你可以在'loadXML'內啓動運行循環嗎? – 2013-03-18 05:28:59