• 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: Remove an object from a defaults suite?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Remove an object from a defaults suite?


  • Subject: Re: Remove an object from a defaults suite?
  • From: Chris Parker <email@hidden>
  • Date: Thu, 28 Aug 2008 14:50:41 -0700


On Aug 28, 2008, at 2:38 PM, Ken Thomases wrote:

On Aug 28, 2008, at 4:03 PM, David Springer wrote:

I use -[NSUserDefaults addSuiteNamed:] to add the defaults from a
previous version of my app to the defaults search domains. This works
fine, except I want to remove a certain key/value pair from the suite.
Is there any way to do this? The best plan I can come up with so far
is to read the old defaults from its plist into an NSMutableDictionary
then add all the keys to the app domain (except the one I want to
remove). But there does not seem to be any API to get
~/Library/Preferences/foo.plist in a nice localizable way...

Definitely don't access the .plist file directly.

I'll second this. :)

One approach is to drop down to Core Foundation's CFPreferences API.

This is the smallest hammer to use; CFPreferencesSetAppValue() is probably what you want here.


Another is to use the "persistent domain" capabilities of NSUserDefaults. Pull in the dictionary for the domain, make a mutable copy, modify it, and then write the whole domain back out.

This is overkill; use the CFPreferences API instead.

.chris

--
Chris Parker
Cocoa Frameworks
Apple Inc.

_______________________________________________

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


References: 
 >Remove an object from a defaults suite? (From: "David Springer" <email@hidden>)
 >Re: Remove an object from a defaults suite? (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Undocumented Leopard support for overlapping sibling views
  • Next by Date: Re: Quitting all active applications
  • Previous by thread: Re: Remove an object from a defaults suite?
  • Next by thread: How do I create a PDF fle paginated according to my own rules?
  • Index(es):
    • Date
    • Thread