I need to store a persistent data for my Mac application. I’m able to store this data in a plist or NSUserdefaults. But I want to store this persistent data in my application folder, so that when I delete the app (move to trash) from the Mac, this persistent data also will get deleted. I want this to work like that. What would be best approach to do this and how can I store persistent data in my app folder, so that the data also gets deleted when the app is deleted?
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[ud setObject:@"1" forKey:@"APPLAUNCHED"]; // store user default
[ud synchronize];
It is not a good practice to store persistent data in the applications folder. You should use the
Home or Application Support Directory depending on the type of content you want to store
The following describes the Mac Application guidelines
http://developer.apple.com/library/mac/#documentation/General/Conceptual/MOSXAppProgrammingGuide/AppRuntime/AppRuntime.html