Re: Adding something to the login items
Re: Adding something to the login items
- Subject: Re: Adding something to the login items
- From: Arthur VIGAN <email@hidden>
- Date: Sun, 13 Apr 2003 19:37:32 +0200
I changed my code to add a new login item:
int main (int argc, const char * argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSMutableDictionary *myDict = [[NSMutableDictionary alloc] init];
NSUserDefaults *defaults = [[NSUserDefaults alloc] init];
NSMutableArray *loginItems;
[defaults addSuiteNamed:@"loginwindow"];
[myDict setObject:[NSNumber numberWithBool:NO] forKey:@"Hide"];
[myDict setObject:@"/Volumes/My_Path_To_My_App" forKey:@"Path"];
loginItems = [[NSMutableArray arrayWithArray:[[defaults
persistentDomainForName:@"loginwindow"]
objectForKey:@"AutoLaunchedApplicationDictionary"]] retain];
[loginItems removeObject:myDict]; //make sure it's not already in
there
[loginItems addObject:myDict];
[defaults removeObjectForKey:@"AutoLaunchedApplicationDictionary"];
[defaults setObject:loginItems
forKey:@"AutoLaunchedApplicationDictionary"];
[defaults synchronize];
[loginItems autorelease];
[pool release];
return 0;
}
I found this in the cocoa dev list archives, but it still doesn't work.
I really don't see why! If if goes on, I will edit the
loginwindow.plist file prgrammaticaly.
-- Arthur
Le dimanche, 13 avr 2003, ` 14:33 Europe/Paris, Nick Zitzmann a icrit :
On Sunday, April 13, 2003, at 04:25 AM, Arthur VIGAN wrote:
how can my application add something to the login items in the system
preferences?
The preference is stored inside
~/Library/Preferences/loginwindow.plist, inside an array called
"AutoLaunchedApplicationDictionary" and you can interact with this
array by loading the persistent domain "loginwindow" through
NSUserDefaults.
So you can just add a new dictionary object with the appropriate
objects and keys filled out, and put that into the array. That said,
please ask the user before making changes to this preference...
_______________________________________________
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.