iOS Document/File type associations - wildcard UTI

2019-01-18 00:50发布

I have an app which is something of a generic file manager. I would like the "Open in..." functionality present in apps using QLPreviewController, UIDocumentInteractionController, etc to be able to send my app any filetype.

I have created a document type but whether the "Types" is set to " * ", "public. * ", or similar combinations I can't get the app to display for non-specific cases (it does work if I change the UTI to com.adobe.pdf, for example).

On Mac OS X one can set an app to be a generic viewer of all file types - is this not possible on iOS?


EDIT

Going through the docs, I found there are only a handful of primitive UTI types, from which all others inherit

public.item
public.content 
public.database
public.calendar-event
public.message 
public.contact 
public.archive 
public.url-name
public.executable
com.apple.resolvable 

Of these, many are clearly never going to be instances of files.

I may have been overly ambitious trying to create a wildcard test: I tried public.item and it worked on a pdf file from mail. Since the docs state that public.item is the "Base type for the physical hierarchy.", that could mean this is the wildcard, ie " public.item = * "

Worst case scenario, I could add item, content, database, and archive and hope for the best. Best case scenario, item covers everything.

标签: ios uti
2条回答
男人必须洒脱
2楼-- · 2019-01-18 01:03

You need to specify both a UTI for the functional as well as the physical hierarchy. For all files (but excluding bundles) you can use public.data + public.content. For really everything (including symlinks and folders) you would use public.item + public.content.

See how Dropbox.app does it: http://www.cocoanetics.com/2013/01/open-in-all-files/

See my writeup about UTIs here: http://www.cocoanetics.com/2012/09/fun-with-uti/

查看更多
Summer. ? 凉城
3楼-- · 2019-01-18 01:19

public.item works for every type I've tried so far.

查看更多
登录 后发表回答