How do we retrieve UnknownFSObjectIcon.icns these days?

In the good old days, it was possible to retrieve dynamically the UnknownFSObjectIcon.icns icon using:

[[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kUnknownFSObjectIcon)];

Now, this solution is considered to be deprecated (but is still working) by recent macOS SDKs.

[Q] What is the modern equivalent of this solution?

Notes:

  • Yes, reading the file directly works but is more fragile than using a System API.
  • Yes, Xcode suggests to use the iconForContentType: method but I haven't found which UTType should be used.
Answered by Etresoft in 827668022

[Q] What is the modern equivalent of this solution?

There is a similar shape in SF Symbols called "square.dashed".

It's not quite the same, but it's a relatively stable resource.

I guess there wouldn't be any content type for an unknown object. It's unknown, so by definition, you don't know what type it is.

The only truly guaranteed resources are the ones you include with your app.

Accepted Answer

[Q] What is the modern equivalent of this solution?

There is a similar shape in SF Symbols called "square.dashed".

It's not quite the same, but it's a relatively stable resource.

I guess there wouldn't be any content type for an unknown object. It's unknown, so by definition, you don't know what type it is.

The only truly guaranteed resources are the ones you include with your app.

How do we retrieve UnknownFSObjectIcon.icns these days?
 
 
Q