Re: NSAttributedString and bindings
Re: NSAttributedString and bindings
- Subject: Re: NSAttributedString and bindings
- From: Matt Baker <email@hidden>
- Date: Sun, 06 Jun 2004 19:23:13 -0500
As mmalc indicated, NSTextView has a data and a value binding. The
value binding is only enabled when the string is set to not use
formatted text. When multiple fonts is enabled, then you must use the
data binding. The data binding requires an instance of NSData that
contains RTF.
Given that you have an NSAttributedString, you can use....
- (NSData *)RTFDFromRange:(NSRange)range
documentAttributes:(NSDictionary *)dict;
... to generate an NSData that'll plug into the text view's data binding.
This would be an ideal situation to create a value transformer. Say...
@interface AttributedStringToDataTransformer : NSValueTransformer
@end
... that could convert the string in both directions. Then you would
have a universal solution.
b.bum
I want to get an NSString out of a NSTextBox which does allow multiple
fonts and styles.. the ultimate goal is to perform functions on the
unformatted string (like a word count) and also perform calculations on
the styled text (like conversion to a custom XML-based document).
I have a few design questions to answer then:
1. If NSData is ultimately needed should I store an NSData object or an
NSMutableAttributedString?
2. Should I have a separate NSString object in my class for storing the
string equivalent of my styled text, to use in searching and word counts?
3. Suppose I'd like to count the number of italicized words in a
NSTextView. I'd assume that kinda thing would require an
NSMutableAttributedString, but how do I get the NSTextBox's contents
into my NSMutableAttributedString with bindings?
4. I see many of the string object discussions talk about conversion to
an RTF document. does RTF maintain paragraph styles and support more
than ASCII charachters?
I feel like I'm missing something small b ut important here. Thanks for
all your help in the matter.
Matt
_______________________________________________
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.