I’m not going to attach the code for this one directly (it almost 500 lines)
But it is a Swift module that closely replicates the operation of all Xojo File Dialogs
It does require the TextFile module I posted a number of weeks ago, as it is dependant on the “folderitem” class contained there.
Functions
func GetOpenFolderItem(filter:[String]) -> folderitem? {}
func GetSaveFolderItem(filter:[String],defaultName:String="") -> folderitem? {}
func SelectFolder() -> folderitem? {}
Classes
class OpenDialog : templateOpenDialog {}
class SaveAsDialog : templateSaveDialog {}
class SelectFolderDialog : templateOpenDialog{}
These work almost identically to the same named function or class in Xojo, with one outstanding difference.
Each takes an array of File Extensions instead of the FileType as in Xojo. This Swift code then converts those to the corresponding UTI and uses that information.
For example if you indicated
let f = GetSaveFolderItem(["jpg"],"mypic.jpg")
if would actually allow [“jpeg”, “jpg”, “jpe”] as they all belong to the same base UTI
Note : the UTI code was written by Hiroki Kato and found on GitHub