lib/sugarcube/nsuserdefaults.rb in sugarcube-0.13.3 vs lib/sugarcube/nsuserdefaults.rb in sugarcube-0.13.4
- old
+ new
@@ -6,10 +6,14 @@
self.standardUserDefaults.objectForKey(key.to_s)
end
# Sets the value for a given key and save it right away.
def []=(key, val)
- self.standardUserDefaults.setObject(val.to_nsuserdefaults, forKey: key.to_s)
+ if val == nil
+ self.standardUserDefaults.removeObjectForKey(key)
+ else
+ self.standardUserDefaults.setObject(val.to_nsuserdefaults, forKey: key.to_s)
+ end
self.standardUserDefaults.synchronize
end
def remove(key)
self.standardUserDefaults.removeObjectForKey(key)