You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used to have a reference to MobileCoreServices.UTType.Image to correctly (manually) map the UTType identifier for IANA media types image/* and video/*.
However I now get a deprecation warning that MobileCoreServices.UTType.Image is obsolete and I instead should use UniformTypeIdentifiers.UTType. This seems great. Now I don't have to manually map, there's a built-in function that does it for me. However if I try to use: UniformTypeIdentifiers.UTType.GetType("image/*", UTTagClass.MimeType, null), I get a nonsensical auto-generated UTI instead of public.image, and my code further down throws, because PhotosUI.PHPickerResult.ItemProvider.HasItemConformingTo(…) will never match on that auto-generated UTI.
It seems the new API has the right idea, and should allow you to map the IANA media type to UTI, which I previously needed to do using a self-written mapping function. However it doesn't actually seem to correctly deliver on the idea, and since the previous definitions are now deprecated, my code now has to use a self-written mapping function that relies on hard-coded strings, which is worse than the old situation.
Of course this might stem from the fact that there's maybe some ambiguity about wildcard IANA media types, but how else would I end up at the correct UTI? It seems obvious to me that the closest match for public.image is image/*.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I used to have a reference to
MobileCoreServices.UTType.Image
to correctly (manually) map the UTType identifier for IANA media typesimage/*
andvideo/*
.However I now get a deprecation warning that
MobileCoreServices.UTType.Image
is obsolete and I instead should useUniformTypeIdentifiers.UTType
. This seems great. Now I don't have to manually map, there's a built-in function that does it for me. However if I try to use:UniformTypeIdentifiers.UTType.GetType("image/*", UTTagClass.MimeType, null)
, I get a nonsensical auto-generated UTI instead ofpublic.image
, and my code further down throws, becausePhotosUI.PHPickerResult.ItemProvider.HasItemConformingTo(…)
will never match on that auto-generated UTI.It seems the new API has the right idea, and should allow you to map the IANA media type to UTI, which I previously needed to do using a self-written mapping function. However it doesn't actually seem to correctly deliver on the idea, and since the previous definitions are now deprecated, my code now has to use a self-written mapping function that relies on hard-coded strings, which is worse than the old situation.
Of course this might stem from the fact that there's maybe some ambiguity about wildcard IANA media types, but how else would I end up at the correct UTI? It seems obvious to me that the closest match for
public.image
isimage/*
.Beta Was this translation helpful? Give feedback.
All reactions