I am trying to use the new -[NSOpenPanel setAllowedContentTypes:]
and looking for equivalent of -[NSOpenPanel setAllowedFileTypes:[NSImage imageTypes]]
.
Is this equivalent:
openPanel.allowedContentTypes = [UTType.image]
[openPanel setAllowedFileTypes:@[kUTTypeImage]]; //[openPanel setAllowedFileTypes:[NSImage imageTypes]];
NOTE: Converting NSImage.imageTypes
to UTType
arrays are different. 4 identifiers fail conversion ("com.apple.atx", "org.khronos.ktx2", "public.avis", "com.microsoft.cur"
)
let types = NSImage.imageTypes.count //61
let utTypes = NSImage.imageTypes.compactMap { UTType($0) } //57
let coreTypes = CGImageSourceCopyTypeIdentifiers() //59; doesn't have SVG
NOTE2: PDF doesn't conform to UTType.image
print(UTType.pdf.conforms(to: UTType.image)) //false