0

I'm rewriting my app that reads and graphs data created by a physics simulation program. The original version reads the data files but doesn't save any type of document. I'd like to add the ability to write a document file that contains presentation state and a path to the original data file. So the user can open either the original data files (let's say it has extension .xxx) or files my program creates (extension .yyy).

If the user opens an xxx file, I don't want the document to consider the xxx file to be its on-disk representation. Is there a way in readFromData:ofType:error: that I can test to see if the type is xxx and create an Untitled document?

SSteve
  • 9,937
  • 5
  • 44
  • 68

1 Answers1

0

In your app's file type manifest, set the CFBundleTypeRole for the original .xxx type to "Viewer" and the role for the .yyy type to "Editor". That should let Cocoa's document architecture understand that it should open .xxx as untitled and prompt to save as .yyy.

Chuck
  • 222,660
  • 29
  • 289
  • 383
  • I had already done exactly that expecting the behavior you describe. But the file opens as an *xxx* file, not Untitled, and when I select Save a Version, the typeName string passed to `dataOfType:error:` is "xxx". I double-checked after reading your answer and it's definitely set to "Editor" for *yyy* files and "Viewer" for *xxx* files. – SSteve Jun 09 '12 at 06:57