Change icon of alias on desktop?

348 views Asked by At

I have an alias of an actual application on my desktop.

Now i have to change its icon at runtime. I'm using,

[[NSWorkspace sharedWorkspace] 
setIcon:imgAppIcon forFile: shortCutDestPath options:0];

But this changing icon of original file in/Application folder. Instead of alias changing.

1

There are 1 answers

5
R S On BEST ANSWER

I got the answer, instead of creating alias create a hard link at shortCutDestPath of your application:

 [[NSFileManager defaultManager] linkItemAtPath:<application path>
                                                toPath:shortCutDestPath
                                                 error:&error];

To update icon

BOOL result = [[NSWorkspace sharedWorkspace] setIcon:imageIcon
                                       forFile: shortCutDestPath
                                       options:NSExclude10_4ElementsIconCreationOption];