Realm 继承RLMObject

Realm 继承RLMObject,realm,Realm,只是一个关于创建相互继承的领域对象的快速问题 @interface BaseObject : RLMObject @property long commonProp1; @property long commonProp2; @property long commonProp3; @end @interface InheritingObject : BaseObject @property NSString *name; @end @interface SecondInheritingObj

只是一个关于创建相互继承的领域对象的快速问题

@interface BaseObject : RLMObject
@property long commonProp1;
@property long commonProp2;
@property long commonProp3;
@end

@interface InheritingObject : BaseObject
@property NSString *name;
@end

@interface SecondInheritingObject : BaseObject
@property NSString *name2;
@end
因此,BaseObject具有每个继承对象继承的一些属性。这两个继承类是我唯一希望出现在数据库中的类


有什么好方法可以避免BaseObject出现在域中吗?

您可以覆盖
BaseObject上的class方法
+[RLMObject shouldindefaultschema]
并返回false,而您需要在所有子类中再次覆盖相同的方法才能返回true,这样它们就不会被继承的重写方法排除

发件人:

// Returns whether the class is included in the default set of classes persisted in a Realm.

+ (BOOL)shouldIncludeInDefaultSchema;