NSTextView and bindings with manual notification
NSTextView and bindings with manual notification
- Subject: NSTextView and bindings with manual notification
- From: Dominique PERETTI <email@hidden>
- Date: Fri, 6 May 2005 16:45:54 +0200
I'm using bindings to display tasks in an activity window (the
application is svnX (http://www.lachoseinteractive.net/en/community/
subversion/svnx/)).
Each task is an NSDictionary with keys such as : @"stdout",
@"stderr", @"task", etc and also a @"log" key that corresponds to an
NSData which is a combined version of stdout and stderr (stderr being
an attributed string colored in red).
The purpose is to display the log using bindings in an NSTextView.
It works perfectly as long as the task dictionary is updated with
something like that :
[taskObj setValue:[self newRTFDByAppendingString:stdout] forKey:@"log"]
really
Of course, this is unacceptably ineffecient on big logs because a big
attributedString is being remade each time a chunk of stdout is added.
In Tiger there is a new "attributedString" binding available in IB
(not just "data" that expects NSData or "value" that expect a plain
NSString).
(By the way, I don't think this is backward compatible with Panther,
but there is no warning in the compatibility check against 10.3 when
it is used).
So I wanted to use a more efficient NSMutableAttributedString with
an -appendAttributedString: call.
I implemented something like this :
[taskObj willChangeValueForKey:@"log"];
NSMutableAttributedString *log = [taskObj objectForKey:@"log"];
[log appendAttributedString:stdoutAttrStr];
[taskObj didChangeValueForKey:@"log];
Unfortunately, the textView is not updated "live". I have to unselect
and re-select the task to see the change.
What's wrong here ?
I also tried the same with a plain old string, using the "value"
binding.
Now it's updated... once (!) and left incomplete. Have to unselect
and reselect to see the change.
I wondered whether it was a problem with the change being made from a
thread, so I also tried to do the change in the main thread (using
performSelectorInMainThread...). Same problem.
Do you think this is an AppKit/Bindings bug, or am I missing something ?
Thanks.
Dominique PERETTI
http://www.lachoseinteractive.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden