• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTextView won't update via NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextView won't update via NSThread


  • Subject: NSTextView won't update via NSThread
  • From: Dalton Hamilton <email@hidden>
  • Date: Thu, 05 Nov 2009 07:20:17 -0500

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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTextView won't update via NSThread
      • From: "Stephen J. Butler" <email@hidden>
    • Re: NSTextView won't update via NSThread
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Very, Very Simple iPhone SDK Question
  • Next by Date: Porting non-Mac OS X app to Cocoa
  • Previous by thread: Re: Very, Very Simple iPhone SDK Question
  • Next by thread: Re: NSTextView won't update via NSThread
  • Index(es):
    • Date
    • Thread