Re: Binary Data Format for NSTextView
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