Dropping a application onto mine
Dropping a application onto mine
- Subject: Dropping a application onto mine
- From: Andrew James <email@hidden>
- Date: Sat, 10 Mar 2007 12:16:31 +1030
Hi,
Im trying to build a small utility that will add or set the
LSUIElement value of a application when it is dropped onto my
application. I have some snippet of code from another application to
make it set the value but not create it.
So what im basically asking is how would i go about making it so i
can drop the application onto my utility and then for it to detect
that applications bundle and set the Info.plist (adding the
LSUIElement value if needed)
- (void)dockIconVisibility
{
int menuLocation = [[NSUserDefaults standardUserDefaults]
integerForKey:MenuBarLocation];
NSMutableDictionary *dict;
NSString *path;
path = [[[NSBundle mainBundle] bundlePath]
stringByAppendingPathComponent:@"Contents/Info.plist"];
dict = [[[NSMutableDictionary alloc] initWithContentsOfFile:path]
autorelease];
if(dict == NULL)
{
dict = [NSMutableDictionary dictionary];
}
if(menuLocation == 0)
{
if((![[dict objectForKey:@"LSUIElement"] isEqualToString:@"1"]) &&
([[NSFileManager defaultManager] isWritableFileAtPath:path]))
{
[dict setObject:@"1" forKey:@"LSUIElement"];
if(![dict writeToFile:path atomically:YES])
{
NSLog(@"Couldn't write Info.plist.");
//error dialog or exit?
}
//Change the bundle's modification time to let LaunchServices know
we've changed something.
if(utime([[[NSBundle mainBundle] bundlePath] cString], NULL) == -1)
{
NSLog(@"modify time on bundlePath failed.");
//error dialog or exit?
}
}
}
else
{
if((![[dict objectForKey:@"LSUIElement"] isEqualToString:@"0"]) &&
([dict objectForKey:@"LSUIElement"]))
{
[dict setObject:@"0" forKey:@"LSUIElement"];
[dict writeToFile:path atomically:YES];
//Change the bundle's modification time to let LaunchServices know
we've changed something.
if(utime([[[NSBundle mainBundle] bundlePath] cString], NULL) == -1)
{
NSLog(@"modify time on bundlePath failed.");
//error dialog or exit?
}
}
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden