I've a NSTextView in the application window that shows a log of incoming data of a serial port. I append text to the log as it arrives to the application:
NSAttributedString* attrString = [[NSMutableAttributedString alloc] initWithString: text];
NSTextStorage *textStorage = [SerialOutput textStorage];
[textStorage beginEditing];
[textStorage appendAttributedString:attrString];
[textStorage endEditing];
I want to limit the text, for example, to 1000 lines, in order to not collapse the application because it will run indefinitely.
Now I've a provisional solution, based on an NSTimer that clears the log every week and it works but I prefer to implement a clever method, just limiting the text size and create a circular log.
Any idea ? Maybe using method insertAttributedString ?
Regards, Joan