> On Mar 2, 2017, at 2:38 PM, Daryle Walker <dary...@mac.com> wrote:
> 
> I’m trying out my document-based Mac app’s data-read routine, and the code it 
> being skipped. I actually check the typeName (i.e. the UTI) and it doesn’t 
> match. My bundle identifier for the app has capital letters. I base my 
> document’s main type off that identifier, so it also has capital letters. 
> Turns out that the system gives me the UTI in all small letters, so my 
> (Swift) “switch” fails and my no-matching-type code is executed. I know I 
> could switch my bundle ID to all small letters, but I want to know first if 
> this is documented? Or is the small-letters transformation a bug?
> 
> BTW, I looked at the TextEdit sample code, and it uses the type conformance 
> methods instead of an exact string match. Should I be doing that instead? 
> (Although that means no more “switch” statement.)

Before looking at the replies, I tried:

>     override func read(from data: Data, ofType typeName: String) throws {
>         guard UTTypeConformsTo(typeName as CFString, MyTypeUTI as CFString) 
> else {
>             throw CocoaError(.fileReadUnknown)
>         }

and it worked. So I’m going to switch all of my “switch” to “if-else” chains to 
use this function. The app-specific part of my bundle ID is an initialism, so 
I’m reluctant to make it small letters. So it’s debatable whether Apple making 
the UTIs it process in lowercase is a bug, but that Apple doesn’t seem to 
indicate anywhere that you can’t have a bundle-ID/UTI that differs from another 
solely by case definitely is a bug.

Bug # 30819460

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to