Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

patrickq007

macrumors newbie
Original poster
Aug 24, 2009
2
0
Here is a code segment I wrote:

Code:
MyProcessorClass *myInstance = [[MyProcessorClass alloc] init];
// Set some instance variables of myInstance
myInstance.myDelegate = self; // current object implements a delegate

// Start the thread to do the processing...
// "info" is a NSDictionary
[NSThread detachNewThreadSelector: @selector(MyProcessorClass::doTheWork toTarget:myInstance withObject:info];

The application seems to crash the instant I make that call, even though all parameters check out before the call. Any ideas? Something fishy in the selector syntax (most example use a selector to a method in the current class, here I use a selector in a different class)?

Thanks!
 
Where is doTheWork defined? If it's an instance method on MyProcessorClass, then the selector would be @selector(doTheWork). If doTheWork takes an argument, then it should be @selector(doTheWork:).
 
Quite right, thanks! I am new to obj-c and to me at least, what got me confused is the fact that doTheWork: appeared unresolved without specifying its class. I guess that selectors are really like litteral strings and get passed as string at run-time to the target object who knows what method it refers to ...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.