• 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: Binary Data Format for NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binary Data Format for NSTextView


  • Subject: Re: Binary Data Format for NSTextView
  • From: Mike Rossetti <email@hidden>
  • Date: Thu, 6 Dec 2007 14:27:10 -0700

Thanks Malcolm! The data stored for an NSTextView's textStorage is actually RTFD, but I had only tried RTF. The following did the trick:

- (NSString *)plainSummary
{
  NSData *rtfData = [self valueForKey:@"summary"];
  NSAttributedString* rtfSummary
     = [[[NSAttributedString alloc] initWithRTFD:rtfData
	  documentAttributes:nil] autorelease];
  NSString* plainSummary = [rtfSummary string];
  return plainSummary;
}

Oh, and do a setKeys:triggerChangeNotificationsForDependentKey: so I see any changes in summary reflected in plainSummary.

Mike

On Dec 5, 2007, at 10:43 PM, mmalc crawford wrote:
On Dec 5, 2007, at 9:21 PM, Mike Rossetti wrote:

Could someone tell me what the format is of the data managed via a 'data' binding for an NSTextView supporting rich text that is bound to a Core Data binary attribute?

"The NSData contains either the RTF or RTFD representation of the NSTextView contents, depending on the configuration of the NSTextView."
<http://developer.apple.com/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSTextView.html >


You can get the attributed string back with, for example, initWithRTF:documentAttributes:.
<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSAttributedString_AppKitAdditions/Reference/Reference.html#//apple_ref/occ/instm/NSAttributedString/initWithRTF:documentAttributes: >


mmalc


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Binary Data Format for NSTextView
      • From: mmalc crawford <email@hidden>
References: 
 >Binary Data Format for NSTextView (From: Mike Rossetti <email@hidden>)
 >Re: Binary Data Format for NSTextView (From: mmalc crawford <email@hidden>)

  • Prev by Date: Re: Question about NSView's -enterFullScreenMode:withOptions: method
  • Next by Date: -[NSImage TIFFRepresentation] failing on the multiple files icon?
  • Previous by thread: Re: Binary Data Format for NSTextView
  • Next by thread: Re: Binary Data Format for NSTextView
  • Index(es):
    • Date
    • Thread