Re: NSDocument and stationery
Re: NSDocument and stationery
- Subject: Re: NSDocument and stationery
- From: Greg Titus <email@hidden>
- Date: Mon, 22 Sep 2003 11:59:49 -0700
On Sep 22, 2003, at 11:17 AM, Christopher Corbell wrote:
Is there any support for stationery files with
NSDocument, or is there any Cocoa equivalent for
making a document behave as a template for an new
untitled document with content?
It isn't built in to NSDocument, no, but it is fairly easy to hook into
NSDocumentController to add it. If you link with OmniAppKit you'll get
this behavior, for instance.
You just need to replace the implementation of the NSDocumentController
-openDocumentWithContentsOfFile:display: method, call the original
implementation, then check to see if the file has the stationary pad
bit set. If so, just reset the filename to nil. You can see the code
in NSDocumentController-OAExtensions.m for more details.
Or if you want to do it in your own NSDocument subclass, just determine
when you load the file whether it is a stationary pad or not (using the
Carbon FSpGetFInfo() call), and call [self setFileName:nil] if it is.
Hope this helps,
- Greg
_______________________________________________
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.