I have an iphone app, it run some thread to compute search. The search is made calling a time consuming function from a library.
I need to exit from the thread when the app is terminating, otherwise the thread continue to run and the search create problem when i reopen the app.
I tried to subscribe in the thread
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainApplicationWillTerminate) name:@"UIApplicationWillTerminateNotification" object:nil];
And in mainApplicationWillTerminate
-(void)mainApplicationWillTerminate;
{
[NSThread exit];
}
The problem is still present, any idea?