Search code examples
xmlcocoadocument-based

Document-based application, or not?


I am building a beer recipe application in Cocoa. It's has one main window, with a couple of textfields, tableviews etc. I want to be able to Open and Save recipes in XML format. I found some examples of reading/writing XML. Should my application be a document-based application? What are the benefits? All examples I find of document-based applications are using RTF files or binary (drawings) files, never XML.


Solution

  • The file format used with document based applications doesn't matter at all. You can read and write XML if you like.

    The advantages of NSDocument are that open, save, save as and the close button are handled for you, as well as a "Save before quit"-message and various other things.

    I can think of two solutions for a recipe application:

    1. If you really want the user to save the recipes as files you could use a document-based app.
    2. If you want the user to keep a database of recipes I would go for a single window with a database-backend (SQLite or Core Data) and provide an import and export feature. This way, you can also provide the user a search field.

    I think for a beer recipe app, the second solution would give a better user experience because a user is unlikely to edit two recipes at the same time (see YummySoup! for example).

    I hope this answers your question. :)