感谢您的帮助。我需要用图形保存我的RTF。以下适用于文本。我需要做什么才能使其与嵌入式图形一起使用?
再次感谢。保罗。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];
}
答案 0 :(得分:1)
我认为你可以使用NSText方法writeRTFDToFile:atomically:。由于NSTextView是NSText的子类,因此您应该能够执行此操作:
[textView writeRTFDToFile:[[panel URL] path] atomically:YES];