Re: Text Storage
Re: Text Storage
- Subject: Re: Text Storage
- From: Douglas Davidson <email@hidden>
- Date: Mon, 12 Aug 2002 11:01:37 -0700
On Friday, August 9, 2002, at 12:52 PM, Nico wrote:
Is there any way I can delete the first line of an NSTextView's
textStorage?
Saying "the first line" I mean :
[[[myTextStorage componentsSeparatedByString:@"\n"] objectAtIndex:0]
I tried the docs, but I just managed to replace this line by an empty
one.
That's not what I need, I want the second line to become the first one,
etc..
Your question may already have been answered, but there is API on
NSString for dealing with line breaks:
- (void)getLineStart:(unsigned *)startPtr end:(unsigned *)lineEndPtr
contentsEnd:(unsigned *)contentsEndPtr forRange:(NSRange)range;
- (NSRange)lineRangeForRange:(NSRange)range;
This is probably significantly more efficient than
componentsSeparatedByString:, plus it handles line break characters
other than just \n. The second method should do what you want; the
first gives detailed information about the the range for the line
without the line break vs. the range occupied by the line break
character(s).
Douglas Davidson
_______________________________________________
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.