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

Save document using any extension

I'm making a simple plain-text editor in Xcode. Whenever I try to save a document in specific extensions I'll get this error: I get this alert for certain extensions only (.scala, .jade, ...). I have no problem saving a file using most extensions,…
Kevin Chavez
  • 949
  • 1
  • 11
  • 27
0
votes
2 answers

Hacking the NSDocument architecture

I'm working on creating an NSDocument-based app with tabs for documents. I have found that it wasn't really designed for this. Apple designed the architechture to allow multiple windows for a single document but not the other way around. I have it…
calvinlough
  • 362
  • 3
  • 13
0
votes
1 answer

Prevent warning sheet after NSPersistentDocument rename

Whenever my document is renamed , autosaving is blocked and the first save after the rename presents the pictured message. Technically its not an issue as either button takes the user back to a autosavable state but it is confusing for my users. I…
Warren Burton
  • 17,451
  • 3
  • 53
  • 73
0
votes
1 answer

Prevent autoloading of last opened document

Currently, the default behavior of a Cocoa NSDocument based app is for it to open the last document that was opened automatically. How can I prevent this from happening so I can provide my own behavior?
ericg
  • 8,413
  • 9
  • 43
  • 77
0
votes
3 answers

NSImage readFromData problem

I am trying to make a simple document-based cocoa application that can save and load images in pdf files. For the save part, I am using - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError { return [imageView…
ccy
  • 13
  • 4
0
votes
1 answer

Closing a document's window and opening a new one, without closing the document

My app is document-based, but the “document” consists of two folders, not one file. The document's initial window contains a couple of file pickers and a button; the action closes that window and opens a new one showing the results of the operation…
Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
0
votes
2 answers

How to create a new instance of an NSDocument with NSDocumentController?

I tried [[NSDocumentController sharedDocumentController] duplicateDocumentWithContentsOfURL:nil copying:NO …
Colas
  • 3,473
  • 4
  • 29
  • 68
0
votes
0 answers

Can't use NSTextField delegate in NSDocument

I have a document-based project with a view-based tableView bound to a coreData Entity. Now I'd like to use the delegate controlTextDidChange: with a static text inside a tableViewColumn. What I'v done is adding NSTextFieldDelegate to my…
0
votes
0 answers

Notification of core data changes after loading an SQL file

Is there a way to be notified that a previously saved core data document has been loaded?
0
votes
2 answers

How can I intercept the result of openDocument before NSDocument loads?

I am writing a program which will load and process XML data. If the XML file contains a single XML 'Dictionary' then it will need to open an NSDocument window (so far, so good - I can do this!), but if the XML file contains an array of Dictionaries…
headbanger
  • 1,038
  • 1
  • 11
  • 32
0
votes
1 answer

Changing file extension for a 'save as' in NSDocument?

I want to give my app, which currently simply saves out folders, the option of giving these folders file extensions (for saving packages). At the moment, when I do 'saveDocumentAs:', I get the save sheet with 'Untitled' as the suggested filename,…
MT.
  • 227
  • 1
  • 12
0
votes
1 answer

NSDocument and NSFileWrapping saving bad names

My NSDocument subclass using a bundle document type which uses fileWrapperOfType:error: to write data to disk. This works perfectly but eventually it will start to save files with garbled names like "2_#$!@%!#_info.plist" instead of overwriting the…
GenericPtr
  • 677
  • 1
  • 8
  • 18
0
votes
1 answer

Cocoa saveToURL Not Working?

I have an NSDocument subclass that I can save successfully using the File->Save command. When my application runs a specific operation, it updates this file, and needs to automatically save the updated file to disk. I have tried all the…
VikR
  • 4,818
  • 8
  • 51
  • 96
0
votes
0 answers

How to list out Recently Opened documents in iOS?

I have listed out all the documents in NSDocument Directory and im able to get the documents that are recently modified using : NSMutableArray* filesAndProperties = [NSMutableArray arrayWithCapacity:[filesArray count]]; for(NSString* file in…
Sumtwo
  • 31
  • 3
0
votes
1 answer

How to save created PDF in document folder and merge in iOS

Updated I am able to create single PDF page of photo captured with comment in iPHone. On button click I am generating one single PDF page every time and I want those PDF page in single PDF bunch. I am not able to merge the single PDF files in to…
Navnath Memane
  • 265
  • 1
  • 8
  • 25