Answering myself, the solution I found that appears to work is in readFromURL:ofType:error:
to reset the NSDocument
's fileURL, displayName and fileType for the non-native formats.
- (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)error
{
// Handle loading as normal
if (![type isEqualToString:kMyNativeType]) {
[self setFileType:kMyNativeType];
[self setFileURL:nil];
// Without this, all non-native files are displayed as Untitled.
// This sets the window title as the filename without the extension
NSArray *filenameComponents = [[url lastPathComponent] componentsSeparatedByString:@"."];
[self setDisplayName:filenameComponents[0]];
}
return YES;
}
I don't know if this is the correct way, but it appears to work for what I want at the moment, and appears to be what is suggested in https://developer.apple.com/library/mac/documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/AdvancedTopics/AdvancedTopics.html#//apple_ref/doc/uid/TP40011179-CH7-SW8