• 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
re:with java - create, read from, write to preferences file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: Disabling cells in NSTableView
  • Next by Date: Re: Splash screens (last message never went through)
  • Previous by thread: Re: with java - create, read from, write to preferences file
  • Next by thread: Disabling cells in NSTableView
  • Index(es):
    • Date
    • Thread