tags:

views:

264

answers:

3

I'm kinda new to Cocoa and I find it hard to tell when to use NSDocument-based architecture vs normal NSApplication to create my application.

I'm creating these toys project to learn Cocoa:

  1. To-Do list app
  2. Chat program (like Adium)
  3. Finance app (Simple double-entry accouting)
  4. Personal bookmark app
  5. CRM-like contact management

Which one of these should I make as NSDocument-based app?

I will certainly use CoreData whenever I can, but NSDocument and normal NSApplication work with CoreData so I'm not sure if this is relevant to my question.

+1  A: 

Probably none.

You should use NSDocument if you create applications that can open multiple documents like:

  • TextEdit
  • Photoshop
  • TextMate
  • Browser
  • ...
Georg
+2  A: 

The question to ask is not whether you should use NSDocument, but whether you intend to make a document-oriented application. Examples #1, #3, and possibly #5 are apps you could make document-centered (as opposed to library-centered).

Once you've decided whether your app uses documents, the answer to whether you should use NSDocument follows directly from that.

Peter Hosey
+6  A: 

You can use NSDocument whenever the notion of documents makes sense with your application. This is up to you to define what a document is.

An example with a todo list app:

  • If you want to manage a single todo list or a single database containing several todo lists (an approach similar to iPhoto with images or iTunes with songs), then NSApplication is OK.

  • If you want that each todo list be stored in a separate file and to be able to open several todo lists in as many windows in your application (an approach similar to TextEdit with text or Preview with images), then NSDocument is worth considering.

mouviciel