0

Thanks for the help. I need to save my RTF's with graphics. The following works fine for text. What do I need to do to make this work with embedded graphics?

thanks again. paul.

NSSavePanel *panel = [NSSavePanel savePanel];

[panel setAllowedFileTypes:[NSArray arrayWithObject:@"rtf"]];


NSString *outputName = @"Output File";


[panel setCanCreateDirectories:YES];
[panel setCanSelectHiddenExtension:YES];
[panel setNameFieldStringValue:outputName];




[panel beginSheetModalForWindow:theSwatch completionHandler:^(NSInteger result) {

    if (result == NSFileHandlingPanelOKButton){


        [[textView RTFFromRange:NSMakeRange(0, [[textView string] length])] writeToURL:    [panel URL] atomically:YES];
}
Paul
  • 189
  • 10

1 Answers1

2

I think you can use the NSText method, writeRTFDToFile:atomically:. Since NSTextView is a subclass of NSText, you should be able to just do this:

[textView writeRTFDToFile:[[panel URL] path] atomically:YES];
rdelmar
  • 103,982
  • 12
  • 207
  • 218
  • Thanks. This outputs a folder with an RTF.txt doc and a separate image file. I'm trying to save the contents of the textView including an attached image on a single .rtf file. any ideas? – Paul Aug 26 '12 at 03:13
  • I'm not sure you can. What difference does it make if it's a single file or a file package? – rdelmar Aug 26 '12 at 03:50
  • 1
    Thanks again. I had the setAllowedFileTypes set to rtf. Changed it to rtfd and I'm all set. Again - thanks. – Paul Aug 26 '12 at 03:59