Set file extension icon Cocoa

Viewed 152

I'm currently doing it this way but I have to save it twice before the icon shows on the file:

override func save(to url: URL, ofType typeName: String, for saveOperation: NSSaveOperationType, completionHandler: @escaping (Error?) -> Void) {

        NSWorkspace.shared().setIcon(NSApp.applicationIconImage, forFile: url.path, options: NSWorkspaceIconCreationOptions(rawValue: 0))

        super.save(to: url, ofType: typeName, for: saveOperation, completionHandler: completionHandler)
    }

How can I set the icon for my file extension as soon as its being saved?

1 Answers
Related