views:

193

answers:

1

My app freezes whenever I parse an XML feed.

I have tried calling this instead:

[NSThread detachNewThreadSelector:@selector(parseXML) toTarget:self withObject:nil];

which calls:

-(void) parseXML {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    [self parseXMLFileAtURL:path];
    [pool drain]; 
}

but my app has become quite unstable as a result...the iPhone Simulator just crashed with no error warning.

A: 

Rather than calling :

[NSThread detachNewThreadSelector:@selector(parseXML) toTarget:self withObject:nil];

you should call :

[self performSelectorInBackground:@selector(parseXML) withObject:nil]

Your UI is freezing because you are doing lengthy operations in UI Thread.

Gaurav Verma
I get this error: [Switching to thread 12547]Program received signal: “EXC_BAD_ACCESS”.[Switching to thread 12547]
Zac Altman
seems like if i change it to withObject:path instead of nil, it works...
Zac Altman
Now I am getting this: Debugger stopped.Program exited with status value:0.
Zac Altman
it seems the next problem is because of some other code, if you can share it here i can look into it.
Gaurav Verma