Thread "does not implement" error with CLASS method in error string?
I've got the common-seeming error for beginning thread programmers, ".. does not implement selector.." except that it lists a CLASS method, not an instance method. Which makes perfect sense it's defined as an instance method.. Code:
main app delegate header:
@interface LSSampleAppDelegate : NSObject <NSApplicationDelegate>
{
NSWindow *window;
LSDataObject labelOptions;
}
-(void) doPrintDisc: (LSDataObject*) labelOptions;
@property (assign) IBOutlet NSWindow *window;
//-(void) userDidClickStop:(id)sender;
@end
thread function first line (in delegate object):
-(void) doPrintDisc: (LSDataObject*) labelOptions {
thread laun开发者_如何学Cch code:
[NSThread detachNewThreadSelector: @selector(doPrintDisc:)
toTarget: [self class]
withObject: labelOptions];
The error:
*** -[NSThread initWithTarget:selector:object:]: target does not implement selector (*** +[LSSampleAppDelegate doPrintDisc:])
I know, the printDisc method should probably go in the labelOptions object and not the delegate - but I want to get this working before I make another modification.. I've had enough problem today with a malloc error of some kind that seems to show up, only to go away with no apparent reason (it says it's out of memory, but I seriously doubt that it really is unless the lightscribe library itself has a limit on its memory zone) - I assume that the library may run out of memory and then perhaps reset and then the error goes away for a while.
The really odd thing is - earlier today I think I had the thread code actually working..
Try:
[NSThread detachNewThreadSelector: @selector(doPrintDisc:)
toTarget: self
withObject: labelOptions];
instead.
精彩评论