notificationSet as Boolean
@NSManaged var notificationSet: NSNumber?
medicine.setValue(false, forKey: "notificationSet")
Yes, your KVC method will work, but it is bad practice. If you change the name of
notificationSet, you will have to replace strings throughout your project. A typo in the key will compile fine and crash your app at runtime.
Instead, use NSManagedObject subclasses. Xcode can generate those for you automatically.
Also, it normally does not make sense to have a Boolean type as optional. Instead, give it a default value (e.g. "NO") in the model editor. The type is then
NSNumber, rather than
false should work automatically, but if you want to be explicit, you can use
medicine.notificationSet = NSNumber(bool: false)