Re: Problems with the SpellChecker Sample code and more...
Re: Problems with the SpellChecker Sample code and more...
- Subject: Re: Problems with the SpellChecker Sample code and more...
- From: Douglas Davidson <email@hidden>
- Date: Thu, 7 Nov 2002 16:58:43 -0800
On Thursday, November 7, 2002, at 09:00 AM, Andrew Taylor wrote:
Second: the functionality that I really need right now is the ability
to open and read a RTF file and get the text out of it - no
formatting information, just the text.
For this you want to look at the model level, at NSAttributedString.
NSText and NSTextView are at the view level. Try something more like
this:
NSAttributedString *attributedString = [[NSAttributedString alloc]
initWithPath:path documentAttributes:NULL];
NSString *string = [attributedString string];
Also, you'll need to make sure you have a proper path. Cocoa paths are
separated by slashes, not colons. If you prefer, you can use a
CFURL/NSURL and use initWithURL:documentAttributes: instead of
initWithPath:documentAttributes:.
If you're still having problems, try breaking it down into steps.
First use NSData to read the contents of the file as data, then pass it
into -[NSAttributedString initWithRTF:documentAttributes:]. That
should tell you whether the problem is in reading the file, or in
parsing it.
Douglas Davidson
_______________________________________________
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.