私はスウィフトで複合主キーを持つレルムを使用するため、この偉大な解決策が見つかりました:https://github.com/realm/realm-cocoa/issues/1192複合キー
public final class Card: Object {
public dynamic var id = 0 {
didSet {
compoundKey = compoundKeyValue()
}
}
public dynamic var type = "" {
didSet {
compoundKey = compoundKeyValue()
}
}
public dynamic lazy var compoundKey: String = self.compoundKeyValue()
public override static func primaryKey() -> String? {
return "compoundKey"
}
private func compoundKeyValue() -> String {
return "\(id)-\(type)"
}
}
をしかし、私はレルムは怠け者プロパティをサポートしていないことを発見し、私の場合、私はこれを受け取りますエラー:
exception NSException * name: "RLMException" - reason: "Lazy managed property 'compoundKey' is not allowed on a Realm Swift object class. Either add the property to the ignored properties list or make it non-lazy." 0x00007f8a05108060
怠惰な性質のない複合キーを使用することはできますか?