Question

I'm having trouble understanding an Exception, which is thrown a couple of seconds after the home button is pressed.

*** Terminating app due to uncaught exception 'NSDestinationInvalidException', reason: '*** -[GMMLoader performSelector:onThread:withObject:waitUntilDone:modes:]: target thread exited while waiting for the perform'

I'm programing an application, which uses a webservice to load different datasets. The webservice is added to an operationQueue.

WebService* op = 
    [[WebService alloc] initWithSearchString:self.searchBar.text
      notificationCenter:self.progressNotification];
    [self.queue addOperation:op];

[op addObserver:self 
         forKeyPath:@"isFinished" 
            options:NSKeyValueObservingOptionNew 
            context:NULL];

[op release];

In the -(void) start message of the web service, I call this start selector to be performed in the main thread, to be able to interact with the UI.

- (void)start
{
    if (![NSThread isMainThread]){

        [self performSelectorOnMainThread:@selector(start) withObject:nil waitUntilDone:YES];
        return;
    }
    ...
}

All of this works fine, but when I press the home button while the web service is active, I get the mentioned exception.

My guess is, the main thread is halted after the home button was pressed (Is that so?). So the action which is currently running is no longer updated / valid.

I tried to listen to the event UIApplicationWillResignActiveNotification to react on the home button press by canceling or suspend the operations in queue. However this did not help. Am I right with my guess, that this error occurs because of the halted main thread? How else could I manage to stop / cancel the current webservice thread?

Thank you in advance Zerd

Was it helpful?

Solution

I found the error. As it turns out, it was not a problem with the webservice itself, but with a geolocator, which was created and started twice.

Due to this, some kind of zombie thread was created, which would never stop.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top