Why does adding 'dynamic' fix my bad access issues?

后端 未结 2 1971
不思量自难忘°
不思量自难忘° 2020-12-28 13:23

I\'m having a strange issue that appeared with iOS 8 Beta 5 (this issue did not occur with previous versions).

I tried to create an empty project and try to replica

2条回答
  •  猫巷女王i
    2020-12-28 14:01

    This is from the prerelease Swift / Objective-C interoperability documentation:

    Implementing Core Data Managed Object Subclasses

    Core Data provides the underlying storage and implementation of properties in subclasses of the NSManagedObject class. Add the @NSManaged attribute before each property definition in your managed object subclass that corresponds to an attribute or relationship in your Core Data model. Like the @dynamic attribute in Objective-C, the @NSManaged attribute informs the Swift compiler that the storage and implementation of a property will be provided at runtime. However, unlike @dynamic, the @NSManaged attribute is available only for Core Data support.

    So, because of some of the Objective-C runtime features that Core Data uses under the covers, Swift properties need to be specially annotated.

提交回复
热议问题