Re: COCOA: Simplest Way of Formatted Text
Re: COCOA: Simplest Way of Formatted Text
- Subject: Re: COCOA: Simplest Way of Formatted Text
- From: Douglas Davidson <email@hidden>
- Date: Tue, 21 Jan 2003 13:46:04 -0800
On Tuesday, January 21, 2003, at 01:35 PM, Nebagakid wrote:
What I am looking for, for example, is a way to take the entire
contents of an NSTextView (with different colors, fonts, even
pictures) and be able to put that into one string with just saying "I
want this variable to be equal to the Rich Text of this Text View"
.... Am I talking crazy here (I am really new at Cocoa) ?
The rich text contents of the text view are held in its textStorage.
This is an object of class NSTextStorage, which is a subclass of
NSMutableAttributedString. You can deal with it directly, or copy it
into another attributed string. If you wish to pass it to another
application, or store it in persistent form, you will probably want to
either archive it, or else (more commonly) store it in an external
format such as RTF or RTFD (for text with attachments). For this
NSTextView provides methods like RTFFromRange: and RTFDFromRange:
(defined on NSText), and the AppKit's NSAttributedString.h header also
defines various methods for reading and writing RTF and RTFD. You can
take a look at the sources to TextEdit to see some of this in action.
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.