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
1 answer

Saving a "project"-type document (containing sub-documents)

I'm trying to create a "project"-like document, in that it contains subdocuments in a specified directory. I'd like a brand new save of a document to set up that directory with appropriate subdirectories. I'd like a "Save As" to copy all those…
andyvn22
  • 14,696
  • 1
  • 52
  • 74
0
votes
2 answers

What is a document in this context?

I'm a bit confused regarding the document architecture. Lets look at MSN for Mac - what would the document be in that application? The contact list? The text we insert to talk to other people? When the need comes to save or read data into the…
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
0
votes
1 answer

set lastPathComponent string after save

Doc based, QTKit app. When saving, the new filename updates in the active window titleBar. I would also like to display the newly saved filename string in a textField, somewhere else on the opened doc. The code successfully saves the new doc.…
Paul
  • 21
  • 1
0
votes
2 answers

NSDocument read RTFD Data

I am working on a text editor and I want to add RTFD support. After adding the RTFD file type to my Info.plist, I got the message that "readFromFileWrapper:ofType:error: must be overridden for your application to handle file packages." I had a look…
Pripyat
  • 2,937
  • 2
  • 35
  • 69
0
votes
2 answers

"Building a Text Editor in 15 Minutes" reference example not working

I am trying to work on NSDocument, so I tried the Building a Text Editor in 15 Minutes example in the Text System Overview reference. I did some changes to code which was suggested, such as used property and synthesize in place of declaring and…
Devarshi
  • 16,440
  • 13
  • 72
  • 125
0
votes
2 answers

App that is a viewer and editor for the same data type?

The NSDocument system is primarily for files that read and write a particular data type. What about a type that needs to be both read-only and read-write? I'm planning an e-mail app; it would need a read-write document type for composing messages…
CTMacUser
  • 1,996
  • 1
  • 16
  • 27
0
votes
3 answers

Best practices for Document Based Core Data application that takes a long time to open

I have an OS X Cocoa cpplication (10.8-10.9) that opens very large NSDocument (Core Data backed) files that are about 2 GBs or bigger. This takes about 20-40 seconds with the initial load of the document, but then is pretty snappy. The 20-40…
Nathan Dunn
  • 447
  • 5
  • 16
0
votes
1 answer

Check if file exists on iOS and open if it does

Ok. I have an app that parses an XML that contains links to various documents into a TableView. When clicking on the table view row, I would like for the app to check if that file already exists in the NSDocuments folder. If it does, than the…
user717452
  • 33
  • 14
  • 73
  • 149
0
votes
1 answer

How do I detect changes to a Core Data document in iCloud on OS X before the document gets reloaded?

I am currently working on an app that is document based on both OS X and iOS and uses Core Data. To make the documents the same on the two platforms I am using BSManagedDocument on the OS X side. If I launch the app on both platforms simultaneously…
theMikeSwan
  • 4,739
  • 2
  • 31
  • 44
0
votes
1 answer

nested inside the container log directory

I am getting this exception. But I don't know what that means: 2014-02-09 13:44:02.103 HowRU[1731:3e07] +PFUbiquityLocation createUbiquityLocationForPath:withUbiquityRootLocation:: CoreData: Ubiquity: It appears the store file is nested inside the…
0
votes
1 answer

iCloud documents greyed out for guest user

NSDocuments saved by administrator account on iCloud are greyed out when accessed by Guest Account. How does one ensure that NSDocuments saved can be accessed by all users?
Fernando
  • 1
  • 1
0
votes
1 answer

NSDocument and NSFileWrapper: strategy to reduce memory footprint?

Based on the Apple Docs, the recommended practice for using file packages with NSDocument seems to be to keep a reference to the root NSFileWrapper in the custom NSDocument implementation. My question: doesn't this mean that I'll end up with twice…
Mark
  • 6,647
  • 1
  • 45
  • 88
0
votes
0 answers

Waiting for document-based window to finish initialization

In my document-based application, I need controllers tied to the document controller to work with documents once they've been opened. Unfortunately, -readFromURL: ofType: error: fires before these controllers have been initialized and…
John Wells
  • 1,139
  • 1
  • 10
  • 27
0
votes
1 answer

NSDocument + How to access saved versions programmatically

is there a way to access all the saved versions from a NSDocument without using the system versions viewer? What I want is to access all the saved versions programmatically - like having an array or dictionary with all the versions inside...…
Simon Kemper
  • 635
  • 1
  • 7
  • 16
0
votes
1 answer

NSDocument class file bundle not copy right

I created an NSDocument base app, which provides a custom file format, which is a bundle containing multiple resources... all works fine, i can save, load, show package contents etc... the problem is, when i want to sent it over internet, like with…
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179