【发布时间】:2016-08-31 19:01:23
【问题描述】:
我需要一种方法来获取RLMObject 的哈希码,但是当我检查领域实现时,我发现领域(objective-c)在RLMObjectBase 上使用primaryKey:
- (NSUInteger)hash {
if (_objectSchema.primaryKeyProperty) {
id primaryProperty = [self valueForKey:_objectSchema.primaryKeyProperty.name];
// modify the hash of our primary key value to avoid potential (although unlikely) collisions
return [primaryProperty hash] ^ 1;
}
else {
return [super hash];
}
}
我需要更多的hashable 并且如果对象属性不同。
我的问题是:我可以安全地覆盖我的子类上的 -hash 方法,而不会弄乱任何内部 Realm 机制吗?
【问题讨论】:
标签: objective-c hash realm