Re: unit testing NSDocument
Re: unit testing NSDocument
- Subject: Re: unit testing NSDocument
- From: Chris Hanson <email@hidden>
- Date: Wed, 29 Mar 2006 13:49:27 -0800
On Mar 29, 2006, at 10:20 AM, Jesse Grosjean wrote:
I've run into a problem unit testing my NSDocument classes. The
problem is that trying to open a document using the document
controller fails:
[[[NSDocumentController sharedDocumentController]
openDocumentWithContentsOfURL:documentURL display:YES] retain];
I think the reason that this is failing is because the executable
is /Developer/Tools/otest and that doesn't have any Info.plist
associated with it that maps file extensions to my document
classes. And so the sharedDocumentController doesn't know what
class it should use to open the document URL. So my question is
does anyone know how to make the sharedDocumentController load my
apps Info.plist when run from within the otest tool?
You might be able to create a custom subclass of NSDocumentController
that responds to methods like -documentClassForType:, -
fileExtensionsFromType:, -typeForContentsOfURL:error:, and -
typeFromFileExtension: (for example) with the appropriate information
for your application -- possibly information loaded from your
application's Info.plist file. See the NSDocumentController
documentation for more details about these methods and how they might
be called.
Running a test like this against an application rather than a
framework should just work.
-- Chris
_______________________________________________
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