Re: NSDocument or NSXMLDocument?
Re: NSDocument or NSXMLDocument?
- Subject: Re: NSDocument or NSXMLDocument?
- From: Matt Neuburg <email@hidden>
- Date: Sun, 24 Apr 2005 10:09:59 -0700
On Sat, 23 Apr 2005 15:01:48 -0700, Charles Ross <email@hidden> said:
>I have an application I want to build for myself. I'm more of an
>AppleScript person, but I'm taking advantage of this application to
>learn to program Cocoa with Objective-C. I'm very much a newbie with
>Objective-C, but I'm hoping that my application is simple enough for
>me to figure out things as I go.
>
>Basically, the application is a journal. For a while, I've kept this
>in BBEdit as an XML file with a DTD that I designed. I want to write
>a GUI for this so that I don't have to keep entering the tags. I want
>to keep the format of the file as XML so that if I wish, I can edit
>it with BBEdit.
>
>When I create a document based Cocoa project, the template creates
>the MyDocument.h file, which defines the MyDocument class as
>inheriting from the NSDocument class. From what I understand, this
>gives me a lot of functionality for creating a new document. However,
>the NSXMLDocument class is going to give me most of what I need for
>dealing with the XML format. Right now, I'll only be working with one
>document, so the ability to open multiple documents isn't an issue
>yet, but in the future I'd like to be able to add the ability to have
>multiple XML documents open.
>
>So I'm looking for advice on how to proceed. Should make the primary
>class an NSDocument or an NSXMLDocument? Making it an NSDocument will
>give me the flexibility of easily incorporating multiple documents in
>the future, but NSXMLDocument is going to give me the tools to work
>with the format I've chosen, but NSXML doesn't inherit anything from
>NSDocument, so by using it, I lose all of the NSDocument flexibility.
NSDocument and NSXMLDocument have nothing whatever to do with one another.
They neither go together nor do they conflict - they live in completely
different worlds. They use the phrase "document" in their names, but the
resemblence ends there. If you want to write a document-based Cocoa
application, do so (and then you will be writing a subclass of NSDocument).
If you want to parse XML text, do so (and feel free to use NSXMLDocument to
help you). If the documents opened by your app (through NSDocument) happen
to be XML (to be parsed using NSXMLDocument), fine. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden