1

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
1
  • 2
    seems like you found out everything there’s to know. i can’t quite read the exact question. Commented Jul 23 at 9:06

0

Browse other questions tagged or ask your own question.