Hello, I'm doing the below and when I call the -runTask: method is called from the main run loop (no threading) with

                [self runTask:self];

 the NSTextView updates great; however, when I call -runTask via

[NSThread detachNewThreadSelector:@selector(runTask:) toTarget:self withObject:nil];

my app hangs on the attempt to update the myTextView NSTextView

        [[[myTextView textStorage] mutableString] appendString:outString];      

Does anyone have any idea why NSTextView won't update when the code is a thread?
Thanks a lot for any advice.

Dalton Hamilton
Chapel Hill, NC
=====================
- (void)runTask:(id)sender
{
        NSTask *task = [[NSTask alloc] init];
        NSPipe *inPipe = [NSPipe pipe], *outPipe = [NSPipe pipe];
        NSFileHandle *outHandle = [outPipe fileHandleForReading];
        NSData *outData;
        NSString *outString;
        
        
NSMutableArray *arguments = [NSMutableArray arrayWithObjects: @"- l", nil];
        [arguments addObject:@"/Applications"];

        
        [task setLaunchPath:@"/bin/ls"];
        
        
//---------------------------------------------------------------------------------
        [task setArguments: arguments];
        [task setStandardOutput:outPipe];
        [task setStandardError:outPipe];
        [task setStandardInput:inPipe];
        [task launch];
        
        
        outData = [outHandle readDataToEndOfFile];
        [task waitUntilExit];
        [task release];
        
        outString = [[NSString alloc] initWithData:outData
                                                                          
encoding:NSUTF8StringEncoding];
        NSLog(@"%...@\n\n",outString);
        [[[myTextView textStorage] mutableString] appendString:outString];      

        // I've also just tried to do
        // [myTextView setString:outString];
        // and it also hangs when NSThread is used
        
        
}
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to