我需要列出对象的LinkingObjects类型的所有属性。如何列出Realm中的LinkingObjects属性?
class Dogs: Object {
dynamic var name: String = ""
dynamic var age: Int = 0
dynamic var owner: Persons?
}
class Cats: Object {
dynamic var name: String = ""
dynamic var age: Int = 0
dynamic var owner: Persons?
}
class Persons: Object {
dynamic var name: String = ""
dynamic var address: String = ""
let dogs = LinkingObjects(fromType: Dogs.self, property: "owner")
let cats = LinkingObjects(fromType: Cats.self, property: "owner")
}
ObjectSchema正确返回模式:
let person = Persons()
let schema = person.objectSchema
print(schema)
结果:
Persons {
name {
type = string;
objectClassName = (null);
linkOriginPropertyName = (null);
indexed = NO;
isPrimary = NO;
optional = NO;
}
address {
type = string;
objectClassName = (null);
linkOriginPropertyName = (null);
indexed = NO;
isPrimary = NO;
optional = NO;
}
dogs {
type = linking objects;
objectClassName = Dogs;
linkOriginPropertyName = owner;
indexed = NO;
isPrimary = NO;
optional = NO;
}
cats {
type = linking objects;
objectClassName = Cats;
linkOriginPropertyName = owner;
indexed = NO;
isPrimary = NO;
optional = NO;
}
}
然而,objectSchema.properties不返回LinkingObjects性能。
let properties = schema.properties
print(properties)
返回:
[name {
type = string;
objectClassName = (null);
linkOriginPropertyName = (null);
indexed = NO;
isPrimary = NO;
optional = NO;
}, address {
type = string;
objectClassName = (null);
linkOriginPropertyName = (null);
indexed = NO;
isPrimary = NO;
optional = NO;
}]
哪里有狗和猫的属性?
谢谢。
谢谢。看来我们将不得不等待他们...... –