• 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
Finding paragraphs in NSTextStorage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Finding paragraphs in NSTextStorage


  • Subject: Finding paragraphs in NSTextStorage
  • From: Joshua Scott Emmons <email@hidden>
  • Date: Sun, 22 Feb 2004 22:55:54 -0500

Greetings.

I need to be able to calculate the count of the paragraphs in a textview I have. I also need to be able to say, for example, what the first sentence of the eighth paragraph is. NSTextStorage has a handy method called "paragraphs" that does most of the work for me. It returns an NSArray of all the paragraphs in the attributed string. However it comes with this disclaimer:

NSTextStorage defines a set of methods... useful for getting and setting scriptable properties of NSTextStorage objects. In particular, using the... paragraphs method or its corresponding setter method is an inefficient way to manipulate the text storage, since these methods create and return many objects. Instead, use the text access methods defined by NSMutableAttributedString, NSAttributedString, NSMutableString, and NSString to perform character-level manipulation.

I've been kicking it around for three nights now, and I can't figure out a good way to use the NSAttributedString/NSString classes to sort out paragraphs. The above documentation makes me think I'm missing something obvious. Any ideas?

Cheers,
-Josh Emmons
_______________________________________________
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.

  • Follow-Ups:
    • Re: Finding paragraphs in NSTextStorage
      • From: Ali Ozer <email@hidden>
    • Re: Finding paragraphs in NSTextStorage
      • From: Jeremy Dronfield <email@hidden>
  • Prev by Date: Re: Speed comparison: compare:, methodForSelector: & CFNumberCompare()
  • Next by Date: Re: Playing a particular tone
  • Previous by thread: Re: Playing a particular tone
  • Next by thread: Re: Finding paragraphs in NSTextStorage
  • Index(es):
    • Date
    • Thread