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:

35 questions
13
votes
2 answers

Document-based app doesn't restore documents with non-file URLs

I have an application based on NSDocument with an NSDocumentController subclass. My NSDocument works with both file URLs and URLs with a custom scheme which use a web service. I handle much of the loading and saving using custom code, including…
paulmelnikow
  • 16,036
  • 6
  • 56
  • 110
7
votes
1 answer

Remove 'Show/Hide tab bar' menu item

The latest version of macOS Sierra adds a 'Show/Hide tab bar' menu item to the 'View' menu. It does this dynamically. My application already includes its own tab bar using the MMTabBarView library. I would prefer to continue using this library as…
Kyle
  • 16,103
  • 26
  • 123
  • 231
5
votes
2 answers

Cocoa NSDocument: getting autosave to work

Documentation simply states that setting setAutosavingDelay to anything > 0 on the shared doc controller should do it, but after calling [[NSDocumentController sharedDocumentController] setAutosavingDelay:2.0]; in my controller, autosave doesn't…
taco
  • 809
  • 1
  • 9
  • 17
4
votes
0 answers

What is the connection between NSDocumentController and the app delegate?

I'm trying to understand the structure of a Cocoa document based application. I understand that the app delegate responds to events from the application (hence its name) and that the document controller manages all documents and open and save etc.…
4
votes
1 answer

Debug NSDocument app at startup via file drag-and-drop?

Suppose I have an NSDocument app that supports dragging-and-dropping of a file onto its icon to launch the app and open that file. My NSApplicationDelegate has implemented - (BOOL)application:(NSApplication *)sender openFile:(NSString…
JefferyRPrice
  • 895
  • 5
  • 17
3
votes
1 answer

How to prevent a document-based cocoa application to open ANY document?

Recently, a document that was saved caused a crash whenever I would start my app. Is there a way to prevent a doc-based app from opening any document, including a new empty or the last active document(s)? I'd like to do that not by using OSX…
Carelinkz
  • 896
  • 8
  • 26
2
votes
2 answers

How to open a folder or a file with the help of file path in OS x programatically?

I have selected a file using NSOpenPanel and save its url path, but at any time in my os x Application i want to open this file in the default mac application.Suppose if I select an file and click on the open button in my app the file should open in…
2
votes
2 answers

Disable Open Panel in Cocoa Document Based App Launch

I have written a document based application which has disabled auto-creation of new documents when the app launches without restoring a previously opened document. Now I would also like to disable the open panel that appears on app launch. The open…
xizor
  • 1,486
  • 2
  • 16
  • 34
2
votes
0 answers

NSDocument is not in the responder chain

According to the doc (cf. fig 1.10), the NSDocument should be in the responder chain. However, if I try to log the responder chain via the method - (IBAction)logResponderChain:(id)sender { NSResponder *responder = self.view; while…
Colas
  • 3,225
  • 3
  • 25
  • 61
1
vote
1 answer

In what cases [NSDocument fileURL] can be nil?

I'm creating the document with: [NSDocumentController openDocumentWithContentsOfURL:display:completionHandler:] When I'm working with the instance of NSDocument and sometimes I'm getting crashes because document.fileURL == nil. What cases in…
Sanich
  • 1,623
  • 6
  • 21
  • 39
1
vote
1 answer

Circular warnings about Swift static override being final

I have an NSDocumentController subclass that needs to know if it has restored any windows via the NSWindowRestoration protocol. The particular function I'm overriding, documented here, to do this is: override open static func…
Mattie
  • 2,465
  • 2
  • 23
  • 31
1
vote
0 answers

Customize iOS11 Document Based App Template

I need to do the following customizations on the provided iOS 11 Document Based App Template: A library with only my App files, as Procreate example App bellow Get rid of the sidebar browser, so I have a fullscreen that shows only my…
Mane Manero
  • 1,674
  • 1
  • 18
  • 28
1
vote
0 answers

When is NSDocumentController instance instantiated by default in a Document-Based template project?

I created a Document based Cocoa project in Xocode 8.0 on maxOS 10.11.6, using swift 3.0.1. I deleted the mainMenu.xib, document.xib, modified the infolist, and then added my own main function. Becasue I do not use Interface Builder at all. In the…
1
vote
0 answers

Kivy 1.9.1 on El Capitan

I'd recently upgraded to El Capitan, and was going to upgrade to the most recent Kivy. After following the OSX installation instructions, I entered $/Applications/Kivy.app/Contents/MacOS/Kivy in Terminal, which crashed with the following error…
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
  • 1,939
  • 3
  • 23
  • 46
1
2 3