Re: Document Based Application
Re: Document Based Application
- Subject: Re: Document Based Application
- From: Greg Guerin <email@hidden>
- Date: Sun, 08 Jul 2012 14:01:48 -0700
koko wrote:
I have 29 file types and wanted to get away from the if or switch
to open them and let NSDocument pick the right class for me.
As I understand it, an Item in the Document types array of the
plist contains and entry for an NSDocument class.
And yes, each type has a unique extension (possibly multiple).
I.e. type phobia has extensions pho, pho12, pho15 all mapped to
NSDocument subclass MYPhobia.
Use an NSDictionary. The key is the file extension. The value is
the subclass name, or the actual Class object. Cost is one
dictionary lookup. Plus it's extensible, and can be revised without
altering code.
You can also add a level of indirection. The key is still file
extension, but the value is a number (int). Use the number as an
index into an NSArray of classname strings, or the actual Class objects.
The dictionary and/or array can be stored as plists in your app's
Resources sub-dir.
-- GG
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden