4

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?

4

1 回答 1

3

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.

于 2014-11-21T01:37:11.157 回答