Re: Adding something to the login items
Re: Adding something to the login items
- Subject: Re: Adding something to the login items
- From: Isaac Sherman <email@hidden>
- Date: Sun, 13 Apr 2003 17:52:21 -0400
on 4/13/03 1:37 PM, the method -(id)email@hidden:(id)
sender:@"Arthur VIGAN"; returned:
>
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
Unfortunately, doing that would be the quick fix, which could end up broken,
I suppose, and is probably not a good idea. I used your same code, almost,
quite a while ago (July of last year, in fact) and came up with the same
problem. At that same time, I went to the list for help, and Pierre-Olivier
Latour gave me this code, which still works:
NSMutableArray* loginItems;
loginItems = (NSMutableArray*) CFPreferencesCopyValue((CFStringRef)
@"AutoLaunchedApplicationDictionary", (CFStringRef) @"loginwindow",
kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
loginItems = [[loginItems autorelease] mutableCopy];
//Do you stuff on "loginItems" array here
CFPreferencesSetValue((CFStringRef)
@"AutoLaunchedApplicationDictionary", loginItems, (CFStringRef)
@"loginwindow", kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFPreferencesSynchronize((CFStringRef) @"loginwindow",
kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
[loginItems release];
I just pulled this from the archives. It was quite a ways back, but, I hope
it helps.
--
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.