Re: NSString RTF
Re: NSString RTF
- Subject: Re: NSString RTF
- From: Brian Webster <email@hidden>
- Date: Thu, 24 Oct 2002 12:20:37 -0500
RTF, like HTML, is actually plain text, but it just has structure to
it. When you initialize an NSString from the file, it will read in all
the data including the markup, since it only represents plain
characters and doesn't deal with styles. For dealing with RTF, you
should use an NSAttributedString instead. You can use it to parse out
the RTF and then get only the characters, like so:
NSData* rtfData = [[NSData alloc] initWithContentsOfFile:myFileName];
NSAttributedString *attString = [[NSAttributedString alloc]
initWithRTF
Data:rtfData documentAttributes:nil];
NSString* string = [attString string];
On Thursday, October 24, 2002, at 11:59 AM,
email@hidden wrote:
I'm trying to remove the RTF formating from a file I'm
reading it. The file is an RTF file. I can read it
into a NSString just fine, by using something like
below.
Any ideas how I can remove the RTF formating from the
NSString after reading it in? I keep the NSString in
memory, and I don't load it into any other objects,
such as a NSTextView.
NSString *file;
file = [[NSString alloc]
initWithContentsOfFile:myFileName];
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.