I have a .app
. I want to edit the plist.Info
such that if a command line argument of -P "main"
is in the path it will use another of the icons in my resources folder. And if user right clicked and said "keep in dock" it will keep in dock with command line arguments, so on next click it will launch with same command line arguments.
Is this possible?
Worst cast scenario: Any objective-c way to check the path to see if any command line arguments there? Then I'll run setApplicationIconImage
programtically (worst case meaning if the above is not possible) (and then ill also have to programtically fetch the miniaturized windows with [NSWindow miniwindowImage] and draw the mini icon on their msyelf and also listen to future notifications of NSWindowWillMiniaturizeNotification
and do the draw when that notification fires, so this is worst case scenario)
I am not sure I follow you fully.
But I don't think you need to edit the plist.Info and I think it is not good to do that any way.
I would just to write to the apps preference file with CFPreferencesSetValue
and change an entry which determines if the app changes it's icon.
Call made from you argument check:
[self changIcon:(CFBooleanRef)false];
-(void) changIcon:(CFBooleanRef)prefValue
{
CFStringRef appID = CFSTR("com.yourApp.BundleID");
CFStringRef Key = CFSTR("swapIcon");
CFBooleanRef Value = prefValue ;// kCFBooleanTrue;//or kCFBooleanFalse
// Set up the preference.
CFPreferencesSetValue(Key,
Value,
appID,
kCFPreferencesCurrentUser,
kCFPreferencesAnyHost);
// Write out the preference data.
CFPreferencesSynchronize(appID,
kCFPreferencesCurrentUser,
kCFPreferencesAnyHost);
}
Change the icon
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
BOOL swapIcon = [defaults boolForKey:@"swapIcon"];
if (swapIcon ) {
NSImage * b1Image = [NSImage imageNamed:@"bl1"];
[NSApp setApplicationIconImage:b1Image];
}else {
[NSApp setApplicationIconImage:nil];//--Nil will make the app use thenormal icon
}
For a better answer you would need to explain a bit more clearly.