• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Text Storage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Text Storage (From: Nico <email@hidden>)

  • Prev by Date: (no subject)
  • Next by Date: Drawing hidden NSWindow to NSImage then to a NSView
  • Previous by thread: Re: Text Storage
  • Next by thread: Newbie Questions About Methods and Messages
  • Index(es):
    • Date
    • Thread