EXC_BAD_ACCESS error when trying to change Bool property

后端 未结 4 2039
甜味超标
甜味超标 2020-12-17 18:05

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

4条回答
  •  心在旅途
    2020-12-17 19:00

    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)
    }
    }
    

提交回复
热议问题