I'm writing an iOS 11 app where I want to be able to read an Excel file that is dropped onto the app from Files. I've added the drop interaction and canHandle session is called but I can't work out how to identify the UTI of the Excel file that is being dropped.
My code is:
func dropInteraction(_ interaction: UIDropInteraction, canHandle session: UIDropSession) -> Bool {
// Ensure the drop session has an object of the appropriate type
if let UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, "xls" as CFString, nil) {
let UTIString = UTI.takeRetainedValue() as String
let test = session.hasItemsConforming(toTypeIdentifiers: [UTIString]) && session.items.count == 1
return test
}
return false
}
In this example UTIString
resolves to a UTI string that looks like Excel but test
is false when the Excel file is dropped and I can't see a way to work out what the UTI of the file that is being dropped actually is. Is there a way to interrogate the UIDropSession to find out?