Re: A Mac App & helper NSStatusItem - how to share preferences
Re: A Mac App & helper NSStatusItem - how to share preferences
- Subject: Re: A Mac App & helper NSStatusItem - how to share preferences
- From: Steve Cronin <email@hidden>
- Date: Tue, 30 Dec 2008 19:18:16 -0600
Michael;
OK to really perhaps beat the poor horse, is the following kosher?
(NSDictionary *) prefDictionary {
return [(NSDictionary *)CFPreferencesCopyMultiple(NULL,
appBundleID, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost)
autorelease];
}
Steve
Michael said:
Yep, this fixes the leak. Your Copy is balanced with a Release and all
is well.
However, just to be really nitpicky, I'll point out that it's a bit
ugly. You build a new dictionary from the old one, then throw the old
one away. Better to just keep the old one around with something like
this:
return [(id)prefs autorelease];
Or if you're in a garbage collected environment:
return NSMakeCollectable(prefs);
(And you can do both if you're writing dual-mode code.)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden