Finding paragraphs in NSTextStorage
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.