Re: Problem with NSDocument
Re: Problem with NSDocument
- Subject: Re: Problem with NSDocument
- From: Mark Piccirelli <email@hidden>
- Date: Sat, 22 Sep 2001 00:00:23 -0700
Roland --
On Tuesday, September 18, 2001, at 12:20 PM, Roland Laurhs wrote:
Can I use only one NSDocumentController and if yes
can I use this Controller to control two NSDocument Class ?
Yes, there should be one NSDocumentController per running application,
and it can manage instances of multiple subclasses of NSDocument. The
documentation about this at
<
http://developer.apple.com/techpubs/macosx/Cocoa/Reference/ApplicationKit/
ObjC_classic/Classes/NSDocument.html>
is reasonably complete in this regard.
My app do the same thing with the file that app like stuffit or
other kind of compressor app -> I take a file I look if it's a type that
I know if yes I unstuff else I stuff.
I don't know what methods I must overide in NSDocumentController and if
I must overide something (I think yes). So can you help me ?
There may not be NSDocumentController overriding necessary, if your
program's rules are not uniquely complicated. NSDocumentController just
depends on the information in your application bundle's Info.plist to
map file types to NSDocument subclasses to instantiate.
Unfortunately, the above-mentioned documentation is pretty far out of
date when it comes to talking about the Info.plist setup that you have
to do. Identifiers like "NSType" aren't even used anymore! Project
Builder provides a UI for editing Info.plist properties that's complete
enough to be sort of educational in its own right. See the Application
Settings tab in a PB project like Sketch. You'll see the kinds of
Document Types properties that can be set, including file name
extensions, HFS file types, and the document classes that get
instantiated when those file types are encountered.
One word of warning that might eventually be valuable, judging from your
description of what you want to do: in Mac OS 10.0.x, a
CFBundleTypeExtensions entry of "*" does not cause a match with any file
regardless of file name extension, despite what most people would
expect. This is NSDocumentController's fault. Surprisingly, a _blank_
CFBundleTypeExtensions entry does. You can provide more than one
CFBundleTypeExtensions entry per document type. If you have a
NSDocument subclass that you want to be used when the file is of an
unknown type (and it sounds like you might), you should probably put
both "*" and "" entries in that document type's CFBundleTypeExtensions
array.
-- Mark