I\'m trying to change a Bool property and am receiving an EXC_BAD_ACCESS error.
I\'m using XCode 6 and Swift.
The note
property saves fine but t
You can use a swift Bool
with an NSManagedObject - no need for the NSNumber
nonsense. But you need to make sure that in the core data editor, the class is not empty. Enter your objects' name.
I had almost this exactly problem.
Boolean works in Core Data.
The problem I had was in the Core Data Editor under 'CONFIGURATIONS' and 'C' Default. I did not have my entity linked to the correct class.
I'm just considering filing a bug as I have the same issue but if your really want to use Bool still then a workaround is to use this method:
setValue(true, forKey: "completed")
Had the same problem, the solution is indeed to use NSNumber in the @NSManaged property. Additionally you could define a computed Bool property so that you can work with the scalar Boolean in your business logic and not with the NSNumber.
var isCompleted: Bool {
get {
return completed == NSNumber(bool: true)
}
set {
completed = NSNumber(bool: newValue)
}
}