Re: TextView question
Re: TextView question
- Subject: Re: TextView question
- From: Andreas Mayer <email@hidden>
- Date: Fri, 11 Aug 2006 12:25:22 +0200
Am 11.08.2006 um 05:48 Uhr schrieb Jason Jasmin:
NSRange range = NSMakeRange([[logView2 string] length], 0);
Don't know if it makes any difference, but I'm usually using
NSMakeRange([[textView textStorage] length], 0)
NSString *newText = [theText stringByAppendingString:@"\n"];
[logView2 replaceCharactersInRange:range withString:newText];
[logView2 scrollRangeToVisible:range];
Now if I comment the last line out (the scrollRangeToVisible) then
it runs fast enough for me (it seems a little slower than with the
entire logging function disabled, but it's in the same ballpark as
XCode -- close enough).
I'd try and avoid scrolling too often:
[NSObject cancelPreviousPerformRequestWithTarget:self
selector:@selector(scrollLogToEnd) object:nil];
[self performSelector:@selector(scrollLogToEnd) withObject:nil];
- (void)scrollLogToEnd
{
NSRange range = NSMakeRange([[logView2 textStorage] length], 0)
[logView2 scrollRangeToVisible:range];
}
This assumes that you are *not* in a tight loop. Otherwise you'll
probably not see any updates at all.
In case it's still too slow you could add a delay. But that'd be a
bit more complicated.
Andreas
P.S.: Code written in Mail. May contain errors. ;)
_______________________________________________
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