Re: loading content for NSTextView
Re: loading content for NSTextView
- Subject: Re: loading content for NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Mon, 10 May 2004 12:02:54 -0700
On May 10, 2004, at 10:46 AM, Chuck Soper wrote:
I need to load an rtf, rtfd, or html document into an NSTextView. I
believe this is straightforward. I have looked over the documentation,
but it seems like there may be more than one approach.
There are a variety of different methods for getting a document into
the text system, depending for example on whether you want to replace
all of part of the existing text, whether you want to load from a file
or from an NSData, etc. There are also a number of options, depending
for example on whether you want to specify the format of the document
or let the text system figure it out.
You can take a look at the source to TextEdit. It uses
-[NSMutableAttributedString readFromURL:options:documentAttributes:],
calling this method on the text storage (NSTextStorage is a subclass of
NSMutableAttributedString).
The simplest working example of this would be
[[myTextView textStorage] readFromURL:url options:nil
documentAttributes:NULL];
You could start with that and take a look at TextEdit and the
documentation for various refinements. An important header here is
AppKit/NSAttributedString.h, which defines the relevant options and
document attributes.
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.