Get icon for another application in Objective-C
macos, objective-c
Solution
You can use NSWorkspace, e.g.
NSImage *image = [[NSWorkspace sharedWorkspace] iconForFile:path];
If you want to use the app `bundleId` instead of knowing its path, you can do this first
path = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:bundleIdentifier];
Problem
How do I get the icon from another application using Objective-C? I have tried this so far, however it just returns `null`: ``` NSURL *path = [NSURL URLWithString:@"/Applications/Calculator.app"]; NSLog(@"%@", path); NSImage *image = (__bridge NSImage *)(QLThumbnailImageCreate(kCFAllocatorDefault, (__bridge CFURLRef)(path), CGSizeMake(100, 100), (__bridge CFDictionaryRef)(@{(NSString *)kQLThumbnailOptionIconModeKey: @NO}))); NSLog(@"%@", image); ```