Re: NSThread question
Re: NSThread question
- Subject: Re: NSThread question
- From: Peter Ammon <email@hidden>
- Date: Tue, 10 Jul 2001 09:56:22 -0700
on 7/10/01 4:44 AM, Aurilien at email@hidden wrote:
>
I still have an error (signal 10 (SIGBUS)). I'll explain exactly what I
>
do:
>
>
I have a -(void)doImage; method in a custom NSView object. This is the
>
method I'm calling in the new Thread, and it goes like this:
>
>
-(void)doImage
>
{
>
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc ] init];
>
[ self display ];
>
}
>
>
the method in which I call it goes like this:
>
>
-(void) setData:(NSData *) data
>
{
>
myData = [[NSData alloc] initWithData:data];
>
cachedImage = nil;
>
[NSThread detachNewThreadSelector:@selector(doImage) toTarget:self
>
withObject:nil];
>
}
>
>
Still obscure to me what causes the crash...
Your thread entry method must take a single parameter. Replace doImage with
- (void)doImage:(id)anObject;
then replace your NSThread call with
[NSThread detachNewThreadSelector:@selector(doImage:) toTarget:self
withObject:nil];
I don't think that's causing the crash, however. You can try using
NSApplication's detachDrawingThread:toTarget:withObject:, but your best bet
is to do the rendering itself in a second thread and allow the main thread
to respond to user input.
-Peter