Re: On getting the wrong file type
Re: On getting the wrong file type
- Subject: Re: On getting the wrong file type
- From: Quincey Morris <email@hidden>
- Date: Thu, 02 Jun 2016 12:57:32 -0700
- Feedback-id: 167118m:167118agrif8a:167118sHfO2A24Gd:SMTPCORP
On Jun 2, 2016, at 12:26 , Daryle Walker <email@hidden> wrote:
>
> The NSDocument file handler methods are passed a UTI string of the file's (supposed) type. What error are you supposed to throw when you get an unrecognized UTI? Or can you punt up to super for that default handling?
You don’t say which methods you mean. (Depending on context, “handler” could mean NSDocument action method, NSDocumentController method, some delegate, file coordinator, etc.)
You should not get any file type except those you put in your document file types in your info.plist. So, you could force a crash if you get something unrecognized, or (in the simple case of having only a single document type) you can just ignore the type completely.
In Obj-C I used to be religious about checking this sort of thing early and often, because the dynamism could sometimes propagate incorrect behavior a long way. In Swift, because of the stricter type checking, unexpected values tend to blow up much earlier, so I’ve stopped bothering to put in explicit checks for things that are just going to explode naturally. (The price you pay is that such things are poorly reported when they occur, but OTOH they are never supposed to occur.)
_______________________________________________
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