• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: loading content for NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >loading content for NSTextView (From: Chuck Soper <email@hidden>)

  • Prev by Date: Re: use of c select() style events with the objc run loop
  • Next by Date: Adding a gui
  • Previous by thread: loading content for NSTextView
  • Next by thread: Handling NSMenuItem Selections
  • Index(es):
    • Date
    • Thread