Re: Dropping a application onto mine
Re: Dropping a application onto mine
- Subject: Re: Dropping a application onto mine
- From: email@hidden
- Date: Wed, 14 Mar 2007 22:26:45 +0800
Hi,
you can obtain a NSBundle once you get the path of that application
by invoking [NSBundle bundleWithPath:fullPath];
after you get the bundle, you can then use your code to modify its
info.plist.
HTH,
James
On Mar 10, 2007, at 9:46 AM, Andrew James wrote:
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
_______________________________________________
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