Swift + CoreData: Can not set a Bool on NSManagedObject subclass - Bug?

前端 未结 6 1330
谎友^
谎友^ 2020-12-16 13:02

I have a little strange issue which I can\'t seem to figure out, I have a simple entity with a custom NSManagedObject subclass:

@objc(EntityTest) class Entit         


        
6条回答
  •  [愿得一人]
    2020-12-16 13:20

    You can downcast your property from NSNumber to Bool type like this:

    var someBoolVariable = numberValue as Bool    
    

    It works for me in this way:

    self.twoFactorAuthEnabledSwitch.enabled = userProfile?.twoFactorEnabled as Bool
    

提交回复
热议问题