Search code examples
macoscocoansdocumentnsdocumentcontroller

How to create a new instance of an NSDocument with NSDocumentController?


I tried

[[NSDocumentController sharedDocumentController] duplicateDocumentWithContentsOfURL:nil
                                                                            copying:NO
                                                                        displayName:nil
                                                                              error:NULL] ;

but it is not working. I have the error

typeForContentsOfURL:error: must be overridden for your application to support non-'file:' URLs.

Solution

  • Did you try like this below:-

       [[NSDocumentController sharedDocumentController]newDocument:self];