NSWorkSpace SetIcon not Refreshing

741 views Asked by At

I'm using NSWorkSpace setIcon:forFile:options: on a folder.

However, while the API returns success(true) every time the api is utilized, sometimes the Icon is not updated on the folder.

I've noticed creating a new file inside of the folder will trigger the icon to reappear, which leads me to believe that Finder needs to refresh the folder.

Is there a way to determine when the Icon has actually been set, and the folder needs to be refresh? And is there a way to refresh the folder without creating & deleting a file quickly?

1

There are 1 answers

4
Edo On BEST ANSWER

Turns out there is a function to help notify Finder of the file change.

NSWorkSpace noteFileSystemChanged does this.

https://developer.apple.com/documentation/appkit/nsworkspace/1579268-notefilesystemchanged

However, it does not seem to work for folder icon changes.

Seems like the only option is to create/delete a file.