Hi
I've just joined, so this is my first post. I am working on my first project to help me learn Swift/iOS coming from a Python,PHP,SQL,JavaScript background. So Core Data is new to me and having a little problem trying to work out how to do the following in Core Data. I have done a lot of reading and asking questions. This problem doesn't seem this easy in Core Data, maybe I'm bad at explaining... 😐 But here goes, any help greatly appreciated, I'm a newb remember 😁
I have the following app I am trying to build, just a little player tracker for some sport games. I'll show my rough modelling
class Player: NSManagedObject {
// Player has a name and belongs to a team
@NSManaged var name: String
@NSManaged var team: Team?
}class Team: NSManagedObject {
// Team has a name, Set of Players and Set of Games
@NSManaged var name: String
@NSManaged var players: Set<Player>
@NSManaged var games: Set<Game>
}class Game: NSManagedObject {
// Game has a Set of Teams, the date and Set of Players who played in the game
@NSManaged var teams: Set<Team>
@NSManaged var date: NSDate
@NSManaged var played: Set<Player>
/*
Here in each Game I had planned to store a dictionary of each Player and how many minutes they'd played so:
<Player A : 65, Player B: 20...>
*/
}This it seems isn't as easy as I thought and I've asked a few different people on forums and some didn't know how.
So I wondered what is the correct Core Data way to model data like this? I am a newb so might not get everything you say, but will do my best.
Thanks 🙂
Jonny