Class: NSUserDefaults
- Defined in:
- lib/cocoa/sugarcube-nsuserdefaults/nsuserdefaults.rb
Class Method Summary collapse
-
.[](key) ⇒ Object
Retrieves the object for the passed key.
-
.[]=(key, val) ⇒ Object
Sets the value for a given key and save it right away.
- .remove(key) ⇒ Object
Class Method Details
.[](key) ⇒ Object
Retrieves the object for the passed key
5 6 7 |
# File 'lib/cocoa/sugarcube-nsuserdefaults/nsuserdefaults.rb', line 5 def [](key) self.standardUserDefaults.objectForKey(key.to_s) end |
.[]=(key, val) ⇒ Object
Sets the value for a given key and save it right away.
10 11 12 13 14 15 16 17 |
# File 'lib/cocoa/sugarcube-nsuserdefaults/nsuserdefaults.rb', line 10 def []=(key, val) if val == nil self.standardUserDefaults.removeObjectForKey(key) else self.standardUserDefaults.setObject(val.to_nsuserdefaults, forKey: key.to_s) end self.standardUserDefaults.synchronize end |
.remove(key) ⇒ Object
19 20 21 22 |
# File 'lib/cocoa/sugarcube-nsuserdefaults/nsuserdefaults.rb', line 19 def remove(key) self.standardUserDefaults.removeObjectForKey(key) self.standardUserDefaults.synchronize end |