• 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
Re: TextView question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >TextView question (From: Jason Jasmin <email@hidden>)
 >Re: TextView question (From: Andreas Mayer <email@hidden>)
 >Re: TextView question (From: Jason Jasmin <email@hidden>)

  • Prev by Date: Unified toolbar emptiness
  • Next by Date: Re: Why doesn't Apple's installer let me choose architecture?
  • Previous by thread: Re: TextView question
  • Next by thread: Re: TextView question
  • Index(es):
    • Date
    • Thread