• 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: NSTextView with RTF as string?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView with RTF as string?


  • Subject: Re: NSTextView with RTF as string?
  • From: Nicko van Someren <email@hidden>
  • Date: Fri, 6 May 2005 14:04:22 +0100

On 6 May 2005, at 13:32, John Timmer wrote:

I've got some RTF that I've generated manipulating a string's contents in code.  I need to put that into a Text View.  If I try the following:
   
    [rtfText writeToFile: [@"~/Desktop/blurk.rtf" stringByExpandingTildeInPath] atomically: YES];
    [textView replaceCharactersInRange: NSMakeRange(0,0) withRTF: [NSData dataWithBytes: [rtfText UTF8String] length: [rtfText length]]];


The file I write is properly formatted RTF and opens in Text Edit as desired.  The Text View, however, is filled with gibberish (properly formatted gibberish for the most part, but gibberish).  Is this a problem with text encoding?  Should I be using something other than UTF8String?

You should make the NSData of the RTF text using RTFFromRange:documentAttributes: rather from the UTF8 string. The two codings are completely different.


That said, why not just use use replaceCharactersInRange:withAttributedString: on the NSTextStorage of the view?

	Nicko

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSTextView with RTF as string? (From: John Timmer <email@hidden>)

  • Prev by Date: NSTextView with RTF as string?
  • Next by Date: Re: NSTextView with RTF as string?
  • Previous by thread: NSTextView with RTF as string?
  • Next by thread: Re: NSTextView with RTF as string?
  • Index(es):
    • Date
    • Thread