If I call this
import UIKit
import MobileCoreServices
import Foundation
var fileExtension:CFString = "7z" as CFString
var unmanagedFileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, nil)?.takeRetainedValue();
print(unmanagedFileUTI)
I get
dyn.age8xs8u
as result. I didn't find any information on age8xs8u
. Is this the correct UTI for 7z
?
That means that the "7z" file extension is not known to the MobileCoreServices framework and not registered by any installed application. In that case
UTTypeCreatePreferredIdentifierForTag()
creates and returns a temporary UTI:
If no result is found, this function creates a dynamic type beginning with the dyn prefix. This allows you to pass the UTI around and convert it back to the original tag.
The function returns nil
only if the inTagClass
argument is invalid.
With a valid tag class argument you will always get an UTI back, for arbitrary file identifiers.
You can check if the return value has the prefix "dyn." in order to check if the returned UTI is a dynamically created one or a registered UTI.
According to https://en.wikipedia.org/wiki/7z, the UTI for the 7z file format is "org.7-zip.7-zip-archive".