Re: NSTextView won't update via NSThread
Re: NSTextView won't update via NSThread
- Subject: Re: NSTextView won't update via NSThread
- From: Dalton Hamilton <email@hidden>
- Date: Sun, 08 Nov 2009 08:41:32 -0500
On Nov 6, 2009, at 5:08 PM, Stephen J. Butler wrote:
On Fri, Nov 6, 2009 at 3:50 PM, Dalton Hamilton <email@hidden> wrote:
Well, from the code you've shown us, you call "[outHandle
readDataToEndOfFile]". Which means it waits for all the data before
updating the view. So yes, the view will be empty until the tool is
complete because that's what you told it to do.
I meant it should update the NSTextView each time a task is called.
It was waiting until the runCommand was called 30 times and everything
was done and then suddenly all the text would showup in the
NSTextView. It should have blocked until the task was over for each
log file, then updated the TextView for each entry of runCommand
method and new task.
If you want to update as the tool outputs stuff, you need to
readInBackgroundAndNotify and run the runloop. You can do all this
without threads...
I like this idea and have been working on this since I received your
email.
I'm having two problems now:
Two problems.
1. The first problem is that when I enter runCommand with
sequentially each time asking it to parse a new log file, the python
script produces output text but not all the output from the Python
script makes it to the NSTextView. The output (or text inside the
NSTextView) isn't complete for each log file and this seems random.
This is why, when you look at my code, you'll see a final read after
the [task waitUntilExit] and that doesn't solve the problem really.
2. The second problem is the application hangs using this method. If
I don't use the readInBackgroundAndNotify and simply use NSThread and
performSelectorOnMainThread it never hangs and I get full text output.
Here is small piece of my code:
http://web.me.com/dalton/Cocoa_Notes/NSTextView_NSThread.html
Thanks a lot.
Dalton Hamilton
_______________________________________________
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