Questions tagged [nsdocumentcontroller]

An NSDocumentController object manages an application's document.It is available Apple's AppKit framework. This [tag:NSDocumentController] can be tagged with issues related with opening documents etc using NSDocumentController. Available in Mac OS X v10.0 and later.

An NSDocumentController instance is an administrator of a document-based application. It is responsible for servicing user requests to create, open, and save documents. NSDocumentController serves the integral role of the document factory. NSDocument knows how to load a file's contents as the document's data, and NSDocumentController knows how to create NSDocument objects under different circumstances.

From apple Official document:

An NSDocumentController object manages an application’s documents. As the first-responder target of New and Open menu commands, it creates and opens documents and tracks them throughout a session of the application. When opening documents, an NSDocumentController runs and manages the modal Open panel. NSDocumentController objects also maintain and manage the mappings of document types, extensions, and NSDocument subclasses as specified in the CFBundleDocumentTypes property loaded from the information property list (Info.plist).

You can use various NSDocumentController methods to get a list of the current documents, get the current document (which is the document whose window is currently key), get documents based on a given filename or window, and find out about a document’s extension, type, display name, and document class.

Source: NSDocumentController class reference

Related tags:

34 questions
1
vote
1 answer

Call to `[[NSDocumentController sharedDocumentController] recentDocumentURLs]` hangs

I have an app that routinely calls [[NSDocumentController sharedDocumentController] recentDocumentURLs] to rebuild a list of recently opened items. This has been working well for a while now, but I recently got a report that it hangs a user's…
Melllvar
  • 2,056
  • 4
  • 24
  • 47
1
vote
0 answers

Recent documents list gets cleared after app relaunch

I have a non-document-based application in which I would like to use the "Open Recent" menu item to open a recently opened item. I've implemented this using application:openFile: and noteNewRecentDocumentURL: as described here. AppDelegate.m…
DanielGibbs
  • 9,910
  • 11
  • 76
  • 121
1
vote
1 answer

Document-based app's 'New Document' dock menu item won't open new document

My document-based app has a dock menu with a 'New Document' item. The dock menu is made in Interface Builder, its item's action is connected to 'First Responder's -newDocument: The document controller is a subclass of NSDocumentController called…
1
vote
2 answers

Where is the NSDocumentController in Apple's Document Application Template

Apple makes the point that I will rarely need to subclass NSDocumentController. OK, but I expected to see it somewhere in the project produced from the document based application template. Is it in the project, but Apple has "helpfully" hidden it?…
Carl Carlson
  • 500
  • 4
  • 17
1
vote
1 answer

IBOutlet inside document based application

I've created an application document based but I had problem to handle IBOutlet becouse when I selected some controller inside the document in the first window sometime the other same controller in another window document was selected too... Maybe I…
user2970742
1
vote
1 answer

When should I subclass NSDocumentController for OSX app?

I'm building a document-based app with core data support (so my document is NSPersistentDocument) and I'm wondering if I need to subclass NSDocumentController as well as NSWindowController (for every window in my app since I have multiple). I went…
Eugene Gordin
  • 4,047
  • 3
  • 47
  • 80
1
vote
1 answer

Get supported document types

How do you get the list of all supported document types in a Cocoa app, programatically? I expected to find this in NSDocumentController but the closest thing appears to be documentClassNames, a list of NSDocument subclasses.
hpique
  • 119,096
  • 131
  • 338
  • 476
1
vote
2 answers

How to subclass NSDocumentController to only allow one doc at a time

I'm trying to create a Core Data, document based app but with the limitation that only one document can be viewed at a time (it's an audio app and wouldn't make sense for a lot of docs to be making noise at once). My plan was to subclass…
Mark Wheeler
  • 587
  • 2
  • 6
  • 19
0
votes
1 answer

Document Controller search handling of non file: URLs

Global documents with a custom URL scheme? I have a need to cache info via a URL, with a custom scheme - non file:; to allow user access, and otherwise treat such URLs as global so any access via its URL sees the same data. It's just a fancy way to…
slashlos
  • 913
  • 9
  • 17
0
votes
0 answers

Document based app using one single window

I have a document-based macOS application, which is a basic text editor. The default behavior is to create a new window for every opened document. But I want to only have one window displayed at a time and when opening a document or creating a new…
Codey
  • 1,131
  • 2
  • 15
  • 34
0
votes
1 answer

How a macOS document-based app start itself?

I am learning the document-based app architecture of macOS app development, but am confused about it. I created a document-based app in Xcode. The app template created a simple document-based app. It can run, and will create a new document…
zhoudu
  • 623
  • 8
  • 19
0
votes
3 answers

NSCocoaErrorDomain Code=256 Cannot open files in the “md” format

I'm developing a macOS application for editing files, but am getting a rather annoying error when trying to use NSDocumentController.shared.makeDocument to create a new NSDocument instance from a file URL. Below is a simple example of how I am…
Luka Kerr
  • 4,161
  • 7
  • 39
  • 50
0
votes
1 answer

Getting NSDocumentController from NSDocument

I have subclassed both NSDocumentController and NSDocument. Is there a way to get to the MyDocumentController from MyDocument? Currently I have an outlet in my AppDelegate that connects to MyDocumentController, so I can get to it that way, but was…
Trygve
  • 1,317
  • 10
  • 27
0
votes
1 answer

NSDocumentController openDocumentWithContentsOfURL:display:completionHandler: fails

I'm implementing NSApplicationDelegate's application:openFiles in order to get some custom behavior for specific documents. For some documents though, I want the default behavior (which is just opening and displaying them). So after sorting the…
Remco Poelstra
  • 859
  • 6
  • 20
0
votes
3 answers

force NSDocument to save after creation

In its documents, my application uses a lot of assets that are relative to the document path. So the document must be saved before assets can be added. How can I force-call a [NSDocument saveDocumentAs] ? I managed to do parts of it : by creating my…