• 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
UserDefaults (Java)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

UserDefaults (Java)


  • Subject: UserDefaults (Java)
  • From: Simon Wright <email@hidden>
  • Date: Wed, 26 Dec 2001 19:11:25 -0500

I'm trying to do the right thing with UserDefaults and register some defaults. As in...

http://developer.apple.com/techpubs/macosx/Cocoa/Reference/Foundation/Java/
Classes/NSUserDefaults.html

registerDefaults is expecting an NSDictionary so I'm doing this...

NSMutableDictionary appDefaults = new NSMutableDictionary();
appDefaults.setObjectForKey(defaultAutoStart, "autoStart");
appDefaults.setObjectForKey(defaultCycleDelay, "cycleDelay");
myDefaults.registerDefaults(appDefaults);


The variables defaultAutoStart and defaultCycleDelay are a boolean and an integer respectively but the compiler barfs on the setObjectForKey lines with the message...

DataTable.java:71: setObjectForKey(java.lang.Object,java.lang.Object) in com.apple.cocoa.foundation.NSMutableDictionary cannot be applied to (boolean,java.lang.String) [or int version]

I'm sure I'm missing something simple. When I update the UserDefaults from my Preferences window I can use the method...

myDefaults.setIntegerForKey(cycleDelay, "cycleDelay");

and...

myDefaults.setBooleanForKey(autoStart, "autoStart");

The variables cycleDelay and autoStart are also integer and boolean respectively. UserDefaults provides the capability to place integers and booleans. UserDefaults allows one to assign an NSDictionary to hold the default defaults (excuse the pun).

So, I think my question is: how can I get an integer and a boolean into my NSMutableDictionary?

TIA.

Simon


  • Follow-Ups:
    • Re: UserDefaults (Java)
      • From: Evan Coyne Maloney <email@hidden>
    • Re: UserDefaults (Java)
      • From: Chris Parker <email@hidden>
  • Prev by Date: Newbie question about compressing files revisted
  • Next by Date: Stack size
  • Previous by thread: Re: Newbie question about compressing files revisted
  • Next by thread: Re: UserDefaults (Java)
  • Index(es):
    • Date
    • Thread