Re: Storing NSString with attributes + RTF
Re: Storing NSString with attributes + RTF
- Subject: Re: Storing NSString with attributes + RTF
- From: jgo <email@hidden>
- Date: Tue, 4 Dec 2001 19:34:59 -0800
>
Ali Ozer wrote:
>
> On Sunday, 2001 December 2 at 23:58, Ivan Myrvold wrote:
>
>> On sxndag, 2001 desember 2 at 21:38 , Brendan Younger wrote:
>
>> NSTextStorage inherits from NSMutableAttributedString. Therefore you
>
>> can simply call -textStorage and get an NSMutableAttributed string to
>
>> do whatever you want with.
>
>>
>
> OK, so whenever I want to store away the attributed text from
>
> myTextView , I simply do a:
>
> NSMutableAttributedString *myAttributedString;
>
> myAttributedString = [[myTextView textStorage] copy];
>
>
>
> But what should I do when I want the myAttributedString back into
>
> myTextView?
>
>
[[textView textStorage] setAttributedString: myAttributedString]
>
>
should do it. As Brendan said, NSTextStorage inherits from
>
NSMutableAttributedString, which inherits from NSAttributedString.
>
The API for these two classes are in two places:
>
>
<Foundation/NSAttributedString.h>...
>
<AppKit/NSAttributedString.h>...
>
BTW, another way to make attributed strings persistent is to save them
>
off as RTF or RTFD (the latter if you have graphics or attachments in
>
your text). This is good for saving your attributed strings in files,
>
databases, etc. This will not save away your custom attributes though.
Ahh, is there a recommended way to add support for other RTF tags/
attributes? Specific methods to provide in a particular way?
John G. Otto, Eagle Scout, Knight, Cybernetic Praxeologist
Existence, Consciousness, Identity, Life, Liberty, Property, Privacy, Justice