• 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: Document Based Application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Document Based Application


  • Subject: Re: Document Based Application
  • From: koko <email@hidden>
  • Date: Sun, 08 Jul 2012 16:36:58 -0600

Quite nice, thanks GG.

-koko


On Jul 8, 2012, at 3:01 PM, Greg Guerin wrote:

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


_______________________________________________

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

References: 
 >Re: Document Based Application (From: Greg Guerin <email@hidden>)

  • Prev by Date: Re: Document Based Application
  • Next by Date: Arrgh IB constraints
  • Previous by thread: Re: Document Based Application
  • Next by thread: NSFileManager directory lists and hidden files
  • Index(es):
    • Date
    • Thread