Re: Changing icon for a document file
Re: Changing icon for a document file
- Subject: Re: Changing icon for a document file
- From: "M. Uli Kusterer" <email@hidden>
- Date: Wed, 24 Sep 2003 21:49:25 +0200
At 12:47 Uhr -0400 23.09.2003, Tom Gray wrote:
Normally when a document saves the icon listed in the plist is
attached to the document's file. I would like to use a different
icon on occasion, based on the users selection of an alternative
file type in the Save As dialog.
How can I programmatically change the icon used during a file Save
As for a NSDocument?
I think you're doing this backwards. Icons are generally assigned on
a per-type basis. Type of a document is determined by a) its HFS+
type and creator codes, and b) if there are no type/creator codes, it
is assigned bassed on the file name suffix.
So, the official way to do this is to give each kind of document its
own type/creator/extension in the document types list (in the .plist,
PB has a nice GUI for this). AppKit passes in the document type name
you specify there in NSDocument's file-saving methods, which you can
use to know what the user picked.
You could also hack a "custom icon" onto your file, but that'd mean
the user could easily delete that special icon simply by clicking the
file's icon in the info window and hitting backspace. It'd also
involve use of Carbon APIs (though someone wrote an IconFamily Cocoa
class around the Carbon APIs), and it'd needlessly make each of your
files carry around several k of custom icon data.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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.