iOS Document/File type associations - wildcard UTI?
Asked Answered
L

2

9

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.

Lindner answered 5/11, 2011 at 1:19 Comment(0)
L
7

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

Lindner answered 6/11, 2011 at 1:6 Comment(1)
public.item can also match weird things like creator codes in Apple Events, as I found out when I got reports of an app of mine randomly launching on OS X 10.6. I fixed the issue by using public.data instead. (Of course, Apple Events stuff doesn't apply to iOS…)Iiette
H
13

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/

Houlihan answered 12/1, 2013 at 7:42 Comment(1)
To exclude bundles/directories/system-symbolic-files, isn't "public.data" enough?Villasenor
L
7

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

Lindner answered 6/11, 2011 at 1:6 Comment(1)
public.item can also match weird things like creator codes in Apple Events, as I found out when I got reports of an app of mine randomly launching on OS X 10.6. I fixed the issue by using public.data instead. (Of course, Apple Events stuff doesn't apply to iOS…)Iiette

© 2022 - 2024 — McMap. All rights reserved.