I am trying to use the following statement to create a document:
id myDocument = [[NSDocumentController sharedDocumentController] openUntitledDocumentOfType:@"MyClass" display:YES];
Nothing is created and myDocument is always nil despite the fact that MyClass is a real class in the project and inherits from NSDocument.
What I am doing wrong?
The
typein theopenUntitledDocumentOfType:display:method is the document type name as specified in theCFBundleDocumentTypesin your app’sInfo.plistfile, not the name of your document’s class.Specifically, you need to enter the value of the
CFBundleTypeNamekey that corresponds to the type of document you want to open. This value is labelled by default in Xcode’s property list editor as theDocument Type Name:It’s also editable in the
Document Typeseditor in the Info tab of your project settings: