• 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
Everything You Always Wanted to Know About NSUserDefaults But Were Afraid to Ask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Everything You Always Wanted to Know About NSUserDefaults But Were Afraid to Ask


  • Subject: Everything You Always Wanted to Know About NSUserDefaults But Were Afraid to Ask
  • From: petite_abeille <email@hidden>
  • Date: Sat, 18 Jan 2003 18:06:08 +0100

Hello,

A recent thread on java-dev ("OutOfMemoryError") prompted me to write this little hack to automatically discover what are all the NSUserDefaults used by in any Cocoa applications...

If Apple is not going to be forthcoming about the different NSUserDefaults lying around... well... one has to help oneself...

You can find the hack, with it's source code, at:

http://homepage.mac.com/petite_abeille/.cv/petite_abeille/Public/ Glasnost.tgz-link.gz

For those technically inclined, here is how it goes...

The hack is packaged as an InputManager bundle and therefore loaded automatically by any Cocoa apps. For the few Cocoa application not triggering the InputManager, you can always load the bundle manually by running your target app in gdb.

There is only one class: GlasnostUserDefaults. With two methods:

+ (void) initialize setups the class upon loading by substituting its own - (id) objectForKey: instead of NSUserDefaults's one.

- (id) objectForKey: is the "proxy" method that will now be used instead of NSUserDefaults's one. This method simply invoke NSUserDefaults's original implementation and log the key/value it returns.

Pretty basic. Providing a nice UI and the ability to remotely change applications defaults is left as an exercise to the intrepid reader.

Cheers,

PA.

N.B.

This is an hack... It will most likely melt your computer and fry your brain. You have been warned!
_______________________________________________
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.
  • Prev by Date: Re: Why does this leak memory?
  • Next by Date: NSWindow
  • Previous by thread: Re: AppKit deadlock
  • Next by thread: NSWindow
  • Index(es):
    • Date
    • Thread