Best way to write and read a preference

So I have a app that writes out xml files. This app will be distributed to many different macs.

I need a way to have a user select a xml destination folder once and then have the application remember the location every time the app is launched.

I have created a preference window that has the text field that is populated from a “choose folder”

I’m wondering what the best way to store this information is and how to do it.

You need to use NSUserDefaults, which is what preference property list files are based on.

When reading, you normally register default values with registerDefaults_ and a record, and then use objectForKey_. The labels are up to you. To write, you use setObject_forKey_.

Shane, I’m confused. Is there anyway you can give me a example code?

My property is

property xmlhotfolder : missing value

I can sell you a book with chapter and verse :wink:

Have a look around here; it’s been covered in messages before.

Have a look at Apples Cocoa documents. Found here.

There are examples contained in the docs, just need to convert to ASOC.

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/UserDefaults/UserDefaults.html%23//apple_ref/doc/uid/10000059i

All the best

Terry

I was looking same topic during these days and found this thread about user default.