我的问题不仅涉及+ (NSDictionary *)defaultPropertyValues
方法,还涉及+ (NSArray *)ignoredProperties
,+ (NSArray *)indexedProperties
等其他方法。
例如:
//.h - file
@interface A : RLMObject
@property NSString propertyA;
@end
//.m - file
@implementation A
+ (NSDictionary *)defaultPropertyValues {
return @{@"propertyA":@""};
}
@end
比我定义B类继承的形式A
//.h - file
@interface B : A
@property NSString propertyB;
@end
//.m - file
@implementation B
+ (NSDictionary *)defaultPropertyValues {
NSMutableDictionary *defaultValues = [[super defaultPropertyValues]mutableCopy];
[defaultValues setObject:@"" forKey:@"propertyB"];
return defaultValues;
@end
答案 0 :(得分:2)
(免责声明:我为Realm工作。)
如果您只是简单地对RLMObject
进行子类化,则无需在这些类方法上调用super
。
话虽如此,在您的情况下,您随后继承了RLMObject
的子类,然后是,这绝对是确保您不会破坏的好方法父类的功能。
我个人认为这是一种良好的做法,因为它意味着你不会在这些方法中创建冗余信息(即,如果你在课程A
中改变了任何内容,那么{{1}会是很好的原样)。 :)