• 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: Installing a new login item? - Code that works!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Installing a new login item? - Code that works!


  • Subject: Re: Installing a new login item? - Code that works!
  • From: Pierre-Olivier Latour <email@hidden>
  • Date: Wed, 03 Jul 2002 16:13:59 +0200

> However, the code still doesn't work for me...
> [defaults objectForKey:@"AutoLaunchedApplicationDictionary"]
> Returns an array of 0 entries instead of 7 ones (as indicated in [defaults
> persistentDomainForName:@"loginwindow"]).

Apparently, the CFPreference API returns an empty array if host is set to
kCFPreferencesAnyHost instead of kCFPreferencesCurrentHost.

When accessing the array through "[defaults
objectForKey:@"AutoLaunchedApplicationDictionary"]", host is very likely set
to "kCFPreferencesAnyHost" by Cocoa, therefore the incorrect (?) empty
array.

Should I report a bug for it, or is this behavior normal?

******** Code that works fine *******

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];

_____________________________________________________________

Pierre-Olivier Latour email@hidden
Manager and Lead Programmer
French Touch software http://www.french-touch.net

Cool source code: http://www.french-touch.net/CodeWareHouse
_______________________________________________
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.

  • Follow-Ups:
    • Re: Installing a new login item? - Code that works!
      • From: Isaac Sherman <email@hidden>
References: 
 >Re: Installing a new login item? (From: Pierre-Olivier Latour <email@hidden>)

  • Prev by Date: NSEnumerator ordering ?
  • Next by Date: Re: Cocoa stripping resource forks: does Jaguar fix?
  • Previous by thread: Re: Installing a new login item?
  • Next by thread: Re: Installing a new login item? - Code that works!
  • Index(es):
    • Date
    • Thread