How to reset a long log...
How to reset a long log...
- Subject: How to reset a long log...
- From: JoanBa <email@hidden>
- Date: Thu, 6 May 2004 13:14:51 +0200
Hi,
I'm trying to write all messages of an application in a NSTextView
object, which appears in a GUI. I'm using the following code to append
text at the end of the view:
- (void)appendToLog:(NSString *)message {
NSRange endRange;
endRange.location = [[vConsole textStorage] length];
endRange.length = 0;
[vConsole replaceCharactersInRange:endRange withString:message];
endRange.length = [message length];
[vConsole scrollRangeToVisible:endRange];
}
The problem with this approach is that the application crashes with
long logs, due to a 'bounds' issue. In fact the crash dump shows a
problem in call to [NSCFArray objectAtIndex] :
2004-04-10 10:17:42.110 FlyMotion[915] An uncaught exception was raised
2004-04-10 10:17:42.121 FlyMotion[915] *** -[NSCFArray objectAtIndex:]:
index (0) beyond bounds (0)
2004-04-10 10:17:42.130 FlyMotion[915] *** Uncaught exception:
<NSRangeException> *** -[NSCFArray objectAtIndex:]: index (0) beyond
bounds (0)
Thread 2 Crashed:
0 com.apple.Foundation 0x90a5ce78 _NSRaiseError + 0xf8
1 com.apple.Foundation 0x90a5cd5c +[NSException raise:format:] +
0x2c
2 com.apple.Foundation 0x909f14e4 -[NSCFArray objectAtIndex:] +
0x4c
3 com.apple.AppKit 0x92df25cc -[NSLayoutManager(NSPrivate)
_fillGlyphHoleAtIndex:desiredNumberOfCharacters:] + 0x180
4 com.apple.AppKit 0x92dcb0b8 -[NSLayoutManager(NSPrivate)
_glyphIndexForCharacterIndex:startOfRange:okToFillHoles:] + 0x110
5 com.apple.AppKit 0x92dd8644 -[NSLayoutManager(NSPrivate)
_glyphRangeForCharacterRange:actualCharacterRange:okToFillHoles:] +
0xc0
6 com.apple.AppKit 0x92deb540 -[NSLayoutManager
glyphRangeForCharacterRange:actualCharacterRange:] + 0x30
7 com.apple.AppKit 0x92e310a4 -[NSTextView(NSPrivate)
_scrollRangeToVisible:forceCenter:] + 0x200
8 FlyController.ob 0x002851a4 -[FlyController appendToLog:]
+ 0xec (FlyController.mm:132)
9 FlyUDPReceiver.ob 0x00298530 FlyUDPReceiver::msgToLog(char
const*, ...) + 0x168 (FlyUDPReceiver.mm:60)
10 FlyUDPReceiver.ob 0x002986dc
FlyUDPReceiver::formatData(char*, unsigned) + 0x14c
(FlyUDPReceiver.mm:92)
11 FlyUDPReceiver.ob 0x00298f04 FlyUDPReceiver::run() + 0x488
(FlyUDPReceiver.mm:256)
12 thread.ob 0x000f9c88 threadLauncher + 0x44
(thread.cpp:28)
13 libSystem.B.dylib 0x900247e8 _pthread_body + 0x28
How can I know which are the limits of my text ?
What do you recommend to implement a 'circular' log ? When the log is
full, I delete the first lines and I append text at the end, mantaining
the size of the text constant.
Best regards,
Joan B. Altadill
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.