Re: Installing a new login item?
Re: Installing a new login item?
- Subject: Re: Installing a new login item?
- From: Isaac Sherman <email@hidden>
- Date: Wed, 03 Jul 2002 01:30:25 -0400
Just to hop on the bandwagon, I'd like to pop in here. Rather than use the
more Ugh-ish approach of editting loginwindow.plist directly, I want to use
a standard and safe method to add the items. But my code below doesn't
work. Why? I feel like I'm missing something obvious, but I can't seem to
see it. Any suggestions? Comments? Riddles? Thanks...
<code snippet>
NSMutableDictionary * myDict=[[NSMutableDictionary alloc]init];
NSUserDefaults * defaults = [[NSUserDefaults alloc] init];
NSMutableArray * loginItems;
[myDict setObject:[NSNumber numberWithBool:NO] forKey:@"Hide"];
[myDict setObject:[[NSBundle mainBundle] executablePath]
forKey:@"Path"]; //I probably want to use a
//different path, but this works
//for now
loginItems=[[NSMutableArray arrayWithArray:[[defaults
persistentDomainForName:@"loginwindow"]
objectForKey:@"AutoLaunchedApplicationDictionary"]]
retain];
[loginItems removeObject:myDict];//make sure it's not already in there
[loginItems addObject:myDict];
[defaults setObject:loginItems forKey:
@"AutoLaunchedApplicationDictionary"];
[defaults synchronize]; //Just in case the app quits immediately after
[loginItems autorelease];
</code snippet>
Thanks in advance,
sleep.....
--
Isaac Sherman
MotaSoft Software
http://homepage.mac.com/huperzoevs/
_______________________________________________
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.