Re: scrollRangeToVisible is slowing me down
Re: scrollRangeToVisible is slowing me down
- Subject: Re: scrollRangeToVisible is slowing me down
- From: Darkshadow <email@hidden>
- Date: Wed, 23 Feb 2005 08:05:13 -0500
On Feb 23, 2005, at 1:42 AM, Adam wrote:
I have an NSTextView acting as a log. While the app is running it is
constantly writing lines of text to the NSTextView. During times of
heavy traffic the APP lags. I have noticed that one of the biggest
overheads is the scrollRangeToVisible method. Without this method the
text is added to the end of the NSTextView and the user must scroll
down after each line is written. How can I keep the most recently
updated area visible to my user without taking a performance hit.
r = NSMakeRange([[terminalDisplayTextView string]
length],[[terminalDisplayTextView string] length]);
[terminalDisplayTextView scrollRangeToVisible:r];
Thanks,
Adam
If it's not crucial that the user be able to scroll back to the very
beginning of the log session, then you can truncate text from the
beginning of the textStorage after it reaches a certain length. That
will keep scrollRangeToVisible from taking a long time to update - the
less data in the textStorage, the faster scrollRangeToVisible will be
(to a point, anyway). Hmm, and you can probably do that, because if
it's calling scrollPointToVisible often you won't be able to scroll
very far up before something new is logged and the view jumps back to
the bottom (unless you coded around that, of course).
I usually use this to make the end range: NSMakeRange([[textView
textStorage]length], 0)
I couldn't tell you if that is any faster, though. Maybe by a small
amount, since there's two fewer calls, but I doubt that those calls are
adding much overhead anyway.
Darkshadow (aka Michael Nickerson)
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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