Re: Saving a RTFD-file with NSAttributedString
Re: Saving a RTFD-file with NSAttributedString
- Subject: Re: Saving a RTFD-file with NSAttributedString
- From: Douglas Davidson <email@hidden>
- Date: Mon, 4 Feb 2002 13:52:01 -0800
On Saturday, February 2, 2002, at 01:15 PM, Tae-Won Ha wrote:
NSAttributedString *attrString = [[NSAttributedString alloc]
initWithString:@""];
[[attrString RTFDFromRange:NSMakeRange(0, [attrString length])
documentAttributes:nil] writeToFile:aPath atomically:YES];
Well, this probably doesn't do what you want. The problem is that a
.rtfd is not a single file; it's a package, i.e. a directory containing
both rtf and attachments. For writing out to disk, you want
RTFDFileWrapperFromRange:documentAttributes:, which gives you a file
wrapper, which is the programmatic object that manages a package. See
the TextEdit sources for an example (not really more complicated than
the above). RTFDFromRange:documentAttributes: returns you the whole
thing packaged up as an NSData, which is useful (for example) for
writing to a pasteboard or some other serialized format, not for writing
to the disk.
Douglas Davidson