I have a NSTextView textView bind its “data” to “content” property
textView’s rich text support is turned off.
When textView’s content changed, I have its “data” is nil, though its string and rtf is available.
- (NSData*)content ;
- (void)setContent:(NSData *)data;
{
NSString* s = [textView string];
NSData* rtf = [textView RTFDFromRange:NSMakeRange(0, [s length])];
// data == nil
// s != nil
// rtf != nil
}
“data” is not nil if I enable textView’s rich text support.
Why is “data” nil ?
From the docs:
In other words, you must turn on Rich Text support to use this binding. If you just want to bind a plain string, use the
valuebinding or for an attributed string use theattributedStringbinding instead ofdata.