title: How to set a core-data attibute to nil, in Swift?
body: <p>Here is a working Swift function I have:</p>
  
  <pre><code>func myColorFuntion (object:NSManagedObject) -&gt; UIColor {
      if (object.valueForKey("bgColor") == nil) {return UIColor.yellowColor()}
      return NSKeyedUnarchiver.unarchiveObjectWithData(object.valueForKey("bgColor") as! NSData) as! UIColor
  }
  </code></pre>
  
  <p>My question relates to the line with the “if” statement. <code>object.valueForKey("bgColor")</code> starts with a nil value because it has not been defined.
  I can set something not nil for <code>object.valueForKey("bgColor")</code> with code like the following and it works.</p>
  
  <pre><code>let theColorData:NSData = NSKeyedArchiver.archivedDataWithRootObject(UIColor.cyanColor())
  var object:NSManagedObject
  object.setValue(theColorData forKey:"bgColor")
  </code></pre>
  
  <p>But how can I set <code>object.valueForKey("bgColor")</code> back to nil? The few trials I made using nil and NSNull didn’t work.</p>
  
  <p>`</p>