• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problems with the SpellChecker Sample code and more...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Problems with the SpellChecker Sample code and more... (From: Andrew Taylor <email@hidden>)

  • Prev by Date: Re: To all cocoa developers - new cocoa dev forum
  • Next by Date: Re: keyed archiving questions
  • Previous by thread: Problems with the SpellChecker Sample code and more...
  • Next by thread: Problems with the SpellChecker Sample code and more...
  • Index(es):
    • Date
    • Thread