Class: NSUserDefaults

Inherits:
Object
  • Object
show all
Defined in:
motion/core/ns_user_defaults.rb

Overview

Reopens the NSUserDefaults class to add Array like accessors

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object

Retrieves the object for the passed key



6
7
8
# File 'motion/core/ns_user_defaults.rb', line 6

def [](key)
  self.objectForKey(key.to_s)
end

#[]=(key, val) ⇒ Object

Sets the value for a given key and save it right away.



11
12
13
14
# File 'motion/core/ns_user_defaults.rb', line 11

def []=(key, val)
  self.setObject(val, forKey: key.to_s)
  self.synchronize
end