• 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: Opening and Saving an RTFD [Solved]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Opening and Saving an RTFD [Solved]


  • Subject: Re: Opening and Saving an RTFD [Solved]
  • From: "Mark Munz" <email@hidden>
  • Date: Mon, 4 Aug 2008 23:15:49 -0700

It turns out that my code was working correctly. The bug was in
another part of the app.

The problem actually was in use of NSDirectoryEnumerator (via
enumeratorAtPath) which was traversing into packages. So the code
found the RTF file inside the package, which is read in and wrote out,
stripping off the attachments in the process.

A thanks to those folks that offered up some additional options to
help me track down the problem.


On Mon, Aug 4, 2008 at 3:03 PM, Mark Munz <email@hidden> wrote:
> I must be missing something obvious here and I'm hoping someone can
> point it out.
>
> When I try to read in an RTFD and then write it back out, I lose the
> attachments (images) in the file if I open it up again. I'm using a
> filewrapper to write it back out. The images are still in the package,
> but they are no longer in the file when opened via TextEdit.
>
> NSFileWrapper* filewrapper = [[NSFileWrapper alloc] initWithPath:path];
> NSAttributedString* origFile = [[NSAttributedString alloc]
> initWithRTFDFileWrapper:filewrapper
> documentAttributes:&docAttributes];
> if (origFile)
> {
>        NSAttributedString* newFile = origFile;
>        if (newFile)
>        {
>                NSFileWrapper* newFilewrapper = [newFile RTFDFileWrapperFromRange:
>                                                  NSMakeRange(0,
> [newFile length]) documentAttributes:nil];
>                [newFilewrapper writeToFile:path atomically:YES updateFilenames:YES];
>        }
> }
>
> To rule out any changes I might have made to the attributed string, I
> just used the original string and wrote it back to demonstrate the
> problem.
>
> Your help is much appreciated. Thanks.
>
> --
> Mark Munz
> unmarked software
> http://www.unmarked.com/
>



--
Mark Munz
unmarked software
http://www.unmarked.com/
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: [Moderator] - List Guidelines and iPhone SDK NDA status
  • Next by Date: Colour of Symlink
  • Previous by thread: [Moderator] - List Guidelines and iPhone SDK NDA status
  • Next by thread: Colour of Symlink
  • Index(es):
    • Date
    • Thread