Using NSThread (was: console output -> NSTextView)
Using NSThread (was: console output -> NSTextView)
- Subject: Using NSThread (was: console output -> NSTextView)
- From: Koen van der Drift <email@hidden>
- Date: Sun, 30 May 2004 20:07:30 -0400
Hi,
Using the suggestion from a posting I found in the archives, I was able
to direct the output to an NSTextView. However, the output wouldn't
display until all the calculations were done. So after some Googling, I
found that using NSThread could help me here.
This is what I do now:
-(IBAction)start:(id)sender
{
[NSThread detachNewThreadSelector: @selector(run:)
toTarget: self withObject: nil];
}
-(void)run:(id)sender
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Run();
[pool release];
}
Where Run() is the method in the original source code that does all the
work. Indeed the calls to myPrintf now appear immediately on the
screen. I would like to know if this is indeed the proper way to use an
NSThread. Did I miss anything?
thanks,
- Koen.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.