• 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
Losing attachments when saving rtfd
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Losing attachments when saving rtfd


  • Subject: Losing attachments when saving rtfd
  • From: Matthew Weinstein <email@hidden>
  • Date: Tue, 24 Apr 2012 09:31:24 -0700

Dear programmers,

Trying to save an RTFD from an NSAttributedString with attachements. The text saves; the images don't...

I've been scouring the web but can't seem to figure out what's wrong.

I have a NSAttributedString with attachments. I check that the string really has the attachments by using setAttributedString to the textstorage of a NSTextView, and voila, there it is.

But I can't seem to save the attachment. This is what I'm trying:

	//this is a category I found on the interwebs
	myimagets = [[NSTextAttachment alloc] initWithAnImage: myimage];
	//get doc string
	//replace with the attributed string

	myattstr =  [NSMutableAttributedString attributedStringWithAttachment: myimagets];

	//stick on a little text at the end to see how it handles both...
	addon = [[NSMutableAttributedString alloc] initWithString: @"and here's the extra bit"];
	[myattstr appendAttributedString: addon];

	//this is my test to see if the attachment is really there: it works!
	[[myTextView textStorage] setAttributedString: myattstr];


	//here's what fails:
	myfw = [myattstr RTFDFileWrapperFromRange: NSMakeRange(0, [myattstr length])
						   documentAttributes:nil];
	[myfw writeToFile: [@"~/Desktop/outfile.rtfd" stringByExpandingTildeInPath]
		   atomically:YES updateFilenames:YES];
What's created is an rtfd with only the rtf file in it and no images....

Thoughts? Help?

--Matthew Weinstein
_______________________________________________

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

  • Follow-Ups:
    • Re: Losing attachments when saving rtfd
      • From: Douglas Davidson <email@hidden>
    • Re: Losing attachments when saving rtfd
      • From: "email@hidden" <email@hidden>
  • Prev by Date: Re: Updating NSMenu while it's open
  • Next by Date: Re: Updating NSMenu while it's open
  • Previous by thread: Re: NSComboBox
  • Next by thread: Re: Losing attachments when saving rtfd
  • Index(es):
    • Date
    • Thread