The new MobileDocumentPicker for iOS is welcome addition in the latest version. I assume that in the MobileDocumentPicker.open method that the filter string is a UTI like “public.database” or “public.text”. @javier’s blog post only mentions opening PDFs. Is it possible to pass multiple UTIs as a string array (it doesn’t appear to be)? This would be extremely useful where the app can open serval different types of files.
Yep, that is possible. You can use even file type groups previously set in the IDE.
What is the syntax for using multiple UTIs? I have tried:
DocumentPicker1.Open(FileTypeGroup1.SQLitedatabase + FileTypeGroup1.ZIParchive, False)
which for some reason gives me a Nil Object, and
DocumentPicker1.Open("public.database, public.archive", False)
Which lets me open any file (i.e., same as filter = “”). If I specify the UTIs as a string array it also does not work because filter is a string.
It is a bit surprising that, if the folderItem to be opened is already in the app’s Documents folder, the folder item passed is a copy in the temporary folder. I get why Xojo uses a temporary folderItem when the file is outside the app’s document folder but why not just open the file if it is already inside the Documents folder?
Let’s say that you want to allow “.png” and “.pdf” file(s) selection. In that case:
Using a File Type Group:
The code will read:
DocumentPicker1.Open(PDFandPNG.All,True)
If you want to avoid the use of File Type Group(s), the code will read:
DocumentPicker1.Open("application/pdf;image/png",True)
In both cases, the result of presenting the UI for file(s) selection:
As you can see, only the matching files are available for selection
The items you can choose from the DocumentPicker aren’t inside the app’s Documents folder.
The Documents Picker selector is an iOS system-wide provided service, accessing files that are outside the app’s sandboxed folder; so in order your app can work with them the way it works is providing a copy of such files that are saved in the temporary folder inside the sandboxed folders hierarchy of your app.
Actually, at least in the simulator (the only place I have tried it so far), it is entirely possible for the user to use the DocumentPicker to choose a document that is already in the app’s Document folder. The user will then think that they are working on the original document when in fact they are working on a copy in the Temporary folder.
I suppose one could, in code, delete the original in the Documents folder, and then move the one in the temporary folder back into the documents folder (this is what you do in the new example project). If, however, the app has several subfolders in the Documents folder, as mine does (one for each project), one would have to traverse the entire folder structure to find and delete the original and then copy the temp file back into the correct folder. That seems like a lot of overhead instead of just opening the original when it’s already in the documents folder. If different subfolders happen to have files with the same name, that could be a problem.
At very least, the Xojo documentation of this new feature should explicitly state that the file actually opened is a copy in the Temporary file of the selected file and not the file that the user selected. Right now this crucial info is only in a comment in the sample project (thank you for documenting it there!). Also useful in the documentation would be the filter syntax which you helpfully provided in your previous answer.
If one uses a plist that enables access to the app’s documents folder, then…
Tap On My Phone, Find the app’s document folder, find a file inside the document folder or subfolder, and tap on it to open it!
Context: my app is a GIS type app where users have to move files back and forth between desktop and iPhone. They can move an entire zipped project folder into the Files app or the Documents folder for access. As a scientific mapping app, I also want to be sure that users can access their data inside the document folder at any time. This is not an uncommon practice. I can currently see the document folders of at least 25 different apps on my phone.
Yeah, the key I pointed out for the info.plist… hmmm… I can take a look into this to improve the behavior for that scenario. ![]()
That would be great. I’m currently using some declares from the indispensable @Jeremie_L
to accomplish this and it works great but I always like to try official versions of a function/control when it becomes available.



