Losing attachments when saving rtfd
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