• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDocument and stationery
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDocument and stationery


  • Subject: Re: NSDocument and stationery
  • From: Christopher Corbell <email@hidden>
  • Date: Tue, 23 Sep 2003 18:01:00 -0700

Thanks for your help, this did the trick from the app's perspective.
I did find however that it made a difference where I set
the fileName to nil - I could not do it when loading data because
the window was not yet hooked up (setFileName notifies the window
controller), so I check the stationery bit when the document's window is
actually being shown.

Has Apple given up on keeping the Finder savvy about stationery?
Since a modern app has no 'SIZE' resource, there appears to be
no way to set the isStationeryAware bit, so the Finder will always
duplicate stationery files when they're double-clicked.

I found that even AppleWorks 6 fails to work in this regard (the
Finder's copy gets opened).

I understand that one can create a different document type for
templates (as AppleWorks does), but then this defeats the use
of the stationery bit altogether...

- Christopher

On Monday, September 22, 2003, at 11:59 AM, Greg Titus wrote:

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.
_______________________________________________
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.

References: 
 >Re: NSDocument and stationery (From: Greg Titus <email@hidden>)

  • Prev by Date: Re: NSFileManager
  • Next by Date: Silly question: Company name
  • Previous by thread: Re: NSDocument and stationery
  • Next by thread: Declaring large (but not that large) array causes crash?
  • Index(es):
    • Date
    • Thread