Bool Property Cannot be marked dynamic in swift

拟墨画扇 提交于 2019-12-05 02:43:46

The actual problem is that optional booleans cannot be represented in Objective-C (and therefore not marked dynamic). Using a non-optional

dynamic var isRestricted : Bool = false

should solve the problem.

Generally, the concept of "optionals" does not exist in Objective-C, but optional references to instances of NSObject subclasses are bridged to nullable object pointers in Objective-C, so

dynamic var foo: Foo?

is allowed if (and only) if Foo is a subclass of NSObject.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!