Is there a simple way to split a NSAttributedString
so I get only the last 50 or so lines?
NSMutableAttributedString *resultString = [receiveView.attributedText mutableCopy];
[resultString appendAttributedString:[ansiEscapeHelper attributedStringWithANSIEscapedString:message]];
if ([[resultString.string componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] count]>50) {
//resultString = [resultString getLastFiftyLines];
}
is there a simple way to split a NSAttributedString so i get only the last 50 or so lines?
No. You will have to request the string
and determine the range you are interested in, then create a new NSAttributedString
representation derived from the source using an API such as - [NSAttributedString attributedSubstringFromRange:]
:
- (NSAttributedString *)lastFiftyLinesOfAttributedString:(NSAttributedString *)pInput
{
NSString * string = pInput.string;
NSRange rangeOfInterest = ...determine the last 50 lines in "string"...;
return [pInput attributedSubstringFromRange:rangeOfInterest];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With