问题
I have the following structure:
class Entity : Object {
dynamic var Id = 0
dynamic var Title = ""
dynamic var Subtitle = ""
var atttribute : MyProtocol?
}
Is there a way of storing something in attribute? Today is returning nil. If I add dynamic it returns the error:
Property cannot be marked dynamic because its type cannot be represented in Objective-C
Is there any way to store properties that conform to a Protocol as that?
回答1:
No. Realm properties are monomorphic, and Realm needs to know what the concrete object type that will be linked to is at initialization time.
来源:https://stackoverflow.com/questions/32250084/realm-swift-store-a-protocol-type