Is it possible to set an attribute to nil
using NSBatchUpdateRequest
? Passing NSNull()
to propertiesToUpdate
isn't working:
let unlockRequest = NSBatchUpdateRequest(entityName: "MyEntity")
unlockRequest.predicate = NSPredicate(format: "self in %@", myObjectIDs)
unlockRequest.propertiesToUpdate = ["lockDate": NSNull()]
var error: NSError?
myContext.executeRequest(unlockRequest, error: &error)
if let error = error {
log.error("Failed to unlock: \(error)")
}
I don't get any errors, but it doesn't clear the date.
I've also tried setting it to NSExpression(forConstantValue: NSNull())
, but that doesn't work either (forConstantValue
argument does not accept an optional value, so I can't pass it nil
.).