• 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: How do I read RTFD files into a view?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I read RTFD files into a view?


  • Subject: Re: How do I read RTFD files into a view?
  • From: Jim Correia <email@hidden>
  • Date: Wed, 24 May 2006 18:45:15 -0400

On May 24, 2006, at 6:29 PM, Alan Smith wrote:

I can't get an NSView to replace its contents with the contents of a
RTFD file. I tracked the problem and it's that the NSData pointer
never loads the data.

  NSData *rtfdData;
  if ([[NSFileManager defaultManager] fileExistsAtPath:filePath])
  {
      rtfdData = [NSData dataWithContentsOfFile:filePath];
      NSLog(@"file does exist");
  }
  [helpViewer replaceCharactersInRange:NSMakeRange(0, [[helpViewer
string] length]) withRTFD:rtfdData];
  NSLog(@"help file loaded: %@", filePath);


First, a general comment about this code:

rtfdData is not initialized at declaration time. If the file exists, you make the assignment. Otherwise, you use the variable anyway. This needs to be fixed.

+[NSData dataWithContentsOfFile:] wants a file path, and you are passing it the path to a directory (the .rtfd wrapper.)

AppKit provides methods to create an NSAttributedString from the wrapper, which you can then use in the text view.

<http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/Classes/NSAttributedString_AppKitAdditions/ index.html#//apple_ref/doc/uid/TP40004007>

Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • [SOLVED] How do I read RTFD files into a view?
      • From: "Alan Smith" <email@hidden>
References: 
 >How do I read RTFD files into a view? (From: "Alan Smith" <email@hidden>)

  • Prev by Date: Re: How do I read RTFD files into a view?
  • Next by Date: NSNumber's integer approximation of Positive Infinity
  • Previous by thread: Re: How do I read RTFD files into a view?
  • Next by thread: [SOLVED] How do I read RTFD files into a view?
  • Index(es):
    • Date
    • Thread