• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to add an application to the login items?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: Categories, Protocols, Delegates and ToolTips
  • Next by Date: Re: Newbie probably not retaining himself to well...
  • Previous by thread: Re: How to add an application to the login items?
  • Next by thread: Slow reloadData in NSTableView
  • Index(es):
    • Date
    • Thread