UserDefaults (Java)
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