0

I'm threeaing some tasks like this :

RootViewController

- (void)viewDidLoad {
[NSThread detachNewThreadSelector:@selector(findSomething) toTarget:self withObject:nil];
}

- (void) findSomething {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
doMoreThings
[pool release];
}

- (void) doMoreThings {
  doMoreMoreMoreThings on different objects
}

- (void) foundSomething:(NSFoundThing*)foundObj {
    do your stuff
}

oneObject

- (void) doMoreMoreMoreThings {
   do things
[self performSelectorOnMainThread:@selector(foundSomething:) withObject:thingFound waitUntilDone:NO];
}

gives

-[KMLParser foundSomething:]: unrecognized selector sent to instance 0x5888080

What is the problem ?

Jeremy W. Sherman
  • 35,901
  • 5
  • 77
  • 111
Oliver
  • 23,072
  • 33
  • 138
  • 230

1 Answers1

1

The threading is irrelevant. Some of the code you're not showing us is making it so you are sending the foundSomething: selector to an object that doesn't handle that message. Route the message to an object that does handle it, and your problem will go away.

See also "Unrecognized selector sent to instance".

Community
  • 1
  • 1
Jeremy W. Sherman
  • 35,901
  • 5
  • 77
  • 111
  • Whichever object is `self` in the **oneObject** section. – Jeremy W. Sherman Jun 14 '11 at 22:06
  • I'll read some more about threading, but just a question : what would happen if I had a foundSomething method into oneObject class ? What would happens in terms of thread : I already have a main thjread with something running into it... – Oliver Jun 14 '11 at 22:10
  • The `-performSelectorOnMainThread:` methods basically queue up the call. The next time through its run loop, the main thread will call the queued methods, one after the other. If you're blocking the main thread, those methods will also be blocked from running. – Jeremy W. Sherman Jun 14 '11 at 22:13
  • If the `oneObject` class had a `-foundSomething:` method, then you should no longer get that error. – Jeremy W. Sherman Jun 14 '11 at 22:13