rubymotion/BubbleWrap

View on GitHub
motion/core/ns_user_defaults.rb

Summary

Maintainability
A
0 mins
Test Coverage
# Reopens the NSUserDefaults class to add Array like accessors
# @see https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/nsuserdefaults_Class/Reference/Reference.html
class NSUserDefaults

  # Retrieves the object for the passed key
  def [](key)
    self.objectForKey(key.to_s)
  end

  # Sets the value for a given key and save it right away.
  def []=(key, val)
    self.setObject(val, forKey: key.to_s)
    self.synchronize
  end
end