NSTextView problem
NSTextView problem
- Subject: NSTextView problem
- From: Peter <email@hidden>
- Date: Sat, 4 Mar 2006 10:25:40 +0800
I am doing a simple log window of messages similar to terminal
application. Messages are display row by row on a NSTextView and when
it reach to bottom of the window, it should scroll up, make way for
the newer incoming messages.
However after running for a while, after displaying thousands of
line, it stops and the infamous spinning cursor cames out. The whole
application freeze and I can only force quit. I manage to trace down
the culprit, "scrollRangeToVisible" NSText method. When the statement
is commented/remark then recompile for testing, the problem
disappears. By commenting out the statement, however the NSTextView
stops scrolling upwards when messages hit bottom of the view.
I been thinking doing a custom NSView to replace NSTextView but it
looks like a lot of work and may not able to do some of the things
NSTextView do (such as text selection, clipboard copy).
I hope somebody can help me with this.
Is the way around this problem ? Why does it crash it the first place ?
// logText is the NSTextView
//
- (void) addStringToLog:(NSString *) msg
{
NSRange endOfText;
endOfText.location = [[logText string] length];
endOfText.length = 0;
[logText replaceCharactersInRange: endOfText withString: msg];
[logText scrollRangeToVisible: endOfText]; // "culprit"
}
Thanks.
Peter
_______________________________________________
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