我有两种模式:
class Father: SRKObject {
@objc dynamic var name: String?
@objc dynamic var childrens: [Kid] = []
override init() {
super.init()
}
}
class Kid: SRKObject {
@objc dynamic var name: String!
@objc dynamic var father: Father!
override init() {
super.init()
}
}
我把一个对象放在另一个对象中:
let kid = Kid()
kid.name = "Bill"
let father = Father()
father.name = "James Bond"
kid.father = father
最后我提交了我的对象:
father.commit()
当我用Father.query().fetch() as! [Father]
取出父亲时,孩子们并没有被父亲的财产所取代。我不确定我是否理解SharkORM中的关系,但文档对我没有帮助。