Re: How to add an application to the login items?
Re: How to add an application to the login items?
- Subject: Re: How to add an application to the login items?
- From: Mark de Jong <email@hidden>
- Date: Thu, 20 Jun 2002 00:47:22 -0700
Hi!
I'm trying to add my app to the loginwindow.
I was able to get a list of the login window items using NSUserDefaults.
However, if I'm to add anything to it, I get exception errors indicating
that I cannot change things in the "loginwindow" domain.
How can I correctly add my app to the "loginwindow" domain
programatically?
Here's some code that I'm playing with:
=====
NSMutableDictionary *loginDict =
[[NSUserDefaults standardUserDefaults]
persistentDomainForName:@"loginwindow"];
NSMutableArray *appList = [loginDict
objectForKey:@"AutoLaunchedApplicationDictionary"];
NSEnumerator *e;
id appItem;
NSString *myAppPath = [[NSBundle mainBundle] bundlePath];
NSDictionary *myApp =
[NSDictionary dictionaryWithObjectsAndKeys:myAppPath, [NSString
stringWithString:@"Path"],
[NSNumber numberWithBool:NO], [NSString
stringWithString:@"Hide"],
nil];
[appList insertObject:myApp atIndex:0];
// [loginDict
removeObjectForKey:@"AutoLaunchedApplicationDictionary"];
// [loginDict setObject:appList
forKey:@"AutoLaunchedApplicationDictionary"];
// [[NSUserDefaults standardUserDefaults]
setPersistentDomain:loginDict forName:@"loginwindow"];
// show the changes ...
e = [appList objectEnumerator];
while( appItem = [e nextObject] ) {
if( [appItem isKindOfClass:[NSDictionary class]] ) {
NSLog( @"===\nPath: %@", [appItem objectForKey:@"Path"] );
NSLog( @"Hidden status: %d", [[appItem objectForKey:@"Hide"]
boolValue] );
}
}
=====
The commented lines don't seem to work (if uncommented, I get
exceptions).
Thanks for any clues you can offer,
-- Mark
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.