I'm doing an app that loads the contents of viewControllers using NSThread while is reading an XML file.
I have it done as follows:
// Some code...
[NSThread detachNewThreadSelector:@selector(loadXML) toTarget:self withObject:nil];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Read XML, create objects...
// or [NSThread exit];
When you detach new thread, you can no more cancel or exit it from viewDidDisappear etc. These UI specific methods execute only on main thread so the exit/cancel applies to the main thread which is obviously wrong.
Instead of using the detach new thread method, declare NSThread variable in .h and initialize it using
initWithTarget: selector: object: method and cancel it whenever/wherever you want to..