Questions tagged [nsdocument]

NSDocument is an abstract class that defines the interface for documents, objects that can internally represent data displayed in windows and that can read data from and write data to files.

NSDocument is an abstract class that defines the interface for documents, objects that can internally represent data displayed in windows and that can read data from and write data to files. Documents create and manage one or more window controllers and are in turn managed by a document controller. Documents respond to first-responder action messages to save, revert, and print their data.

Conceptually, a document is a container for a body of information identified by a name under which it is stored in a disk file. In this sense, however, the document is not the same as the file but is an object in memory that owns and manages the document data. In the context of the Application Kit, a document is an instance of a custom NSDocument subclass that knows how to represent internally, in one or more formats, persistent data that is displayed in windows.

A document can read that data from a file and write it to a file. It is also the first-responder target for many menu commands related to documents, such as Save, Revert, and Print. A document manages its window’s edited status and is set up to perform undo and redo operations. When a window is closing, the document is asked before the window delegate to approve the closing.

NSDocument is one of the triad of AppKit classes that establish an architectural basis for document-based applications (the others being NSDocumentController and NSWindowController).

References:

NSDocument Class Reference

479 questions
0
votes
2 answers

Recipe for making Cocoa NSDocument packages play well with svn?

I have a tool that writes package-style documents. It's implemented using NSDocument and overrides the following NSDocument methods: - (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError…
Kaelin Colclasure
  • 3,925
  • 1
  • 26
  • 36
0
votes
1 answer

How to use NSDocument to store images

How can I use NSDocument to store the images in Swift iOS programmatically? let alertController = UIAlertController(title: "Choose an option", message: "", preferredStyle: .Alert) let cameraRollAction = UIAlertAction(title: "Camera Roll",…
Rakesh Mohan
  • 601
  • 2
  • 11
  • 23
0
votes
0 answers

cocoa doc based app MVC binds

Suppose there's an doc based app, class Document subclass from NSDocument and has a property of type NSArray. ViewController is the document's windowController's contentViewController, and has a NSArrayController. then how to bind the…
0
votes
1 answer

Collection view crashes when image loading from NS document directory

I loaded the image to collection view which is stored from NS Document directory, but the collection view crashes due to memory pressure. Converted the image in to JPEG format also happening the same problem please give the solution for me.
0
votes
1 answer

Execute different NSDocument subclass according to file extensions

I have written different parsers and different NSDocument subclasses for files with different extensions to visualize the data. I would like to intergrate them together into one application. I am using NSDocument architecture. I am not sure how to…
Emma
  • 57
  • 1
  • 6
0
votes
1 answer

The correct file location to store a plist on device

What is the correct filepath to store a plist on the device. I read this in a tutorial which will work for the computer, would like to know the file location for the device. // write xml representation of dictionary to a file [dictionary…
some_id
  • 29,466
  • 62
  • 182
  • 304
0
votes
1 answer

ignoredWordsInSpellDocumentWithTag, what's the tag?

I suspect I'm missing something very obvious, but looking over the NSSpellChecker I'm stumped about what tag I should use in ignoredWordsInSpellDocumentWithTag et al. My goal is to save and load these from files external to the document itself (the…
Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98
0
votes
1 answer

Protecting the model in document architecture (Cocoa/Swift)

I am writing an OS X document-based application using cocoa/swift. So far I have a model, which is managed by the NSDocument subclass. Custom views are managed by custom view controllers, which update the views to keep them synchronised with the…
George
  • 1,235
  • 10
  • 23
0
votes
0 answers

Are there any common reasons a file in iOS /Documents directory might disappear between launches

I have an app that is storing several files in the Documents directory, that have a good reason persist between launches. I am storing the name of one of them in NSUserDefaults as @"currentGameVideo" and I check to make sure that file still exists…
Cocorico
  • 2,319
  • 3
  • 22
  • 31
0
votes
1 answer

Customising NSDocument's NSSavePanel

As I edit and then try to close a document in my document-based app, an NSSavePanel pops up. It says, "Do you want to save the changes made to the document “Untitled”?" Is there any way to alter this message? -setMessage: does not do anything,…
0
votes
1 answer

Loading NSDocument data from file, but outlets are nil?

I'm writing a Cocoa application that loads data from a file. This involves overriding readFromData:ofType:error:. I'm curious about how people deal with outlets not yet being connected when readFromData:ofType:error: is called. The documentation…
Elector Niklas
  • 151
  • 1
  • 9
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…
0
votes
1 answer

NSDocument callback method signature

I trying to use the runModalSavePanelForSaveOperation method on NSDocument in Swift, but I get an "unrecognized selector sent to instance" exception when the save panel closes. The method call looks like…
Niels
  • 583
  • 5
  • 20
0
votes
1 answer

Strange things creating a new document-based Cocoa application on Xcode

I am new to cocoa development. I just created for the first time a new document type application using core data and notice a few strange things. AppDelegate is practically empty, there is no code to create the core data store, the…
Duck
  • 34,902
  • 47
  • 248
  • 470
0
votes
1 answer

NSDocument detect when a new document is created as opposed to a saved document restored

I found a major problem with the architecture of my Document based app. Basically a store the model (a simple string) in a global variable, every time the text in field changes. I have the document save this string as it's data, and restore…
Gary Simpson
  • 2,677
  • 2
  • 17
  • 18