2
我有擁有球員的球隊的聯賽。一名球員可以屬於不同的球隊和聯賽。一支球隊可以屬於不同的聯賽。我無法與Realm設置這些關係。使用Realm.io與Swift的關係
class League: RLMObject
{
dynamic var name = "name"
dynamic var teams = RLMArray(objectClassName: Team.className())
}
class Team: RLMObject
{
dynamic var name = "name"
var leagues: [League] {
return linkingObjectsOfClass("League", forProperty: "teams") as [League]
}
dynamic var players = RLMArray(objectClassName: Player.className())
}
class Player: RLMObject
{
dynamic var name = "name"
var teams: [Team] {
return linkingObjectsOfClass("Team", forProperty: "players") as [Team]
}
}
我很高興你能夠把事情做好!如果您有任何新問題,請告訴我們! – jpsim 2014-11-26 20:16:34