How to represent Core Data optional Scalars (Bool/Int/Double/Float) in Swift?

前端 未结 4 1609
你的背包
你的背包 2020-12-09 07:13

(first noticed on: Xcode 8.2.1, iOS 10, Swift 3) (still present as of: Xcode 9 beta 3, iOS11, Swift 4)

We all know that the Core Data concept of o

4条回答
  •  遥遥无期
    2020-12-09 07:56

    If you end up here with this:

    @NSManaged var boolAttribute: Bool
    

    and it is not being seen in Objective-C, and you have already disabled "Optional" and enabled "Use Scalar Type" on those attributes, then do yourself a favour.

    Double check you have imported your Swift bridging header into that Objective-C file.

    I did not and, well, I was most of the way to changing my Bools to NSNumbers before smacking my head and realising how foolish I had been.

提交回复
热议问题