- Then you need to implement applicationWillTerminate, and put your code in there.
- You could hard code the path of the preference file by looking in ~/Library/Preferences; but the correct way might be to use NSUserDefaults method removePersistentDomainForName (I haven't tried it, so I'm not sure if that deletes the preference file, but I expect it would).
You could use the delegate of [NSApplication sharedApplication] as described above to store the revelent information rather than using preferences, and that is lost when the application closes .
PS [NSApplication sharedApplication] can be accessed with the constant NSApp.