re:with java - create, read from, write to preferences file
re:with java - create, read from, write to preferences file
- Subject: re:with java - create, read from, write to preferences file
- From: Marc Pergand <email@hidden>
- Date: Sun, 21 Dec 2003 15:14:03 -0800
You have to use NSUserDefaults class:
NSUserDefaults prefs = NSUserDefaults.standardUserDefaults();
Say you have a drawer attached to some window, and you want to record
this state (open/close), we will use a boolean object with the key
"DrawerState".
boolean drawerOpen;
String DrawerStateKey="DrawerState";
To write the state of the drawer:
prefs.setBooleanForKey(drawerOpen,DrawerStateKey);
And to read back this state:
drawerOpen=prefs.booleanForKey(DrawerStateKey);
In your case you want to store a file path, so you have to write:
prefs.setStringForKey(filePath,FilePathKey);
String filePath=prefs.stringForKey(FilePathKey);
There are specific methods for each type of data: array,
boolean,data,dictionary,double,float ....
See Apple documentation for details.
Best regards,
Marc.
_______________________________________________
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.