Re: On getting the wrong file type
Re: On getting the wrong file type
- Subject: Re: On getting the wrong file type
- From: Daryle Walker <email@hidden>
- Date: Thu, 02 Jun 2016 19:52:12 -0400
I'm writing about the load- and save-NSData methods of NSDocument that are supplied when selecting a (non-Core Data) Document-based project template.
Sent from my iPhone
> On Jun 2, 2016, at 3:57 PM, Quincey Morris <email@hidden> wrote:
>
>> 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