Multiple NSDocument Types in a Document-Based Architecture
Multiple NSDocument Types in a Document-Based Architecture
- Subject: Multiple NSDocument Types in a Document-Based Architecture
- From: Jayme Kosior <email@hidden>
- Date: Wed, 9 Jun 2004 23:57:00 -0600
Hello all.
Is it possible to use the document-based architecture with multiple
document types?
That is, instead just creating one subclass of NSDocument, I would like
to create different types of documents in the same application.
Specifically, I need to display 2D, 3D and 4D (3D over time) medical
images and do some image processing on them. Behind the scenes, I am
using some image processing filters written in C++. Unfortunately, the
underlying image representation (header and pixels) for my C++ data
representations use C++ templates. This means that the image type
(i.e. unsigned short, float) and dimension (i.e.. 2D, 4D etc.) must be
defined at compile time. Incidentally, my application will use float
internally, but the dimension will vary from 2D to 4D.
Therefore, I decided I would make one image model (subclass of
NSDocument) for 2D, one for 3D and one for 4D images, while still using
the basic display layout for the document. That is, sliders to move
through the 3rd (image slice) and 4th (time) dimensions, which will be
disabled in the case of 2D images. However, I'm not sure how to
modify the document architecture to allow this.
In the Info.plist file, there is an XML key called
CFBundleDocumentTypes, and within it, a key called NSDocumentClass.
The value for this key holds the name of the NSDocument class when
using the initial template provided with XCode. I am assuming that I
could add another CFBundleDocumentTypes Key, and fill it in with nearly
the same information for all 2D, 3D and 4D images, with the exception
of the NSDocumentClass.
However, I'm not sure how I would instantiate the correct NSDocument
subclass to correspond with a file a random file that is opened.
Currently, I have code that can read an image header, and load the
image using the appropriate image type. The file extensions for all
the images are the same, but the content is different.
Am I on the right track with this line of thinking?
Are there any examples on the web that deal with this issue?
Should I be using the Document Architecture for this problem?
I have only been programming in Cocoa for 1.5 weeks, but I'm sure
enjoying it. I just need to get my application development started to
keep my boss happy with my decision to use Cocoa. Seeing GUI components
is progress to them :)
Thank you for your time.
Sincerely,
Jayme Kosior
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.