How to structure a Core Data object model whose class has many calculated properties?

213 Views Asked by At

Using Swift 4

Problem:

I have a core data object graph for a soccer league with two entities: Team and Games, related with a one to many relationship (each Team can have many Games). Each game has two statistics: "goals for", and "goals against". I would like to calculate wins, losses, ties, and points scored game (which is an average). It would be a simple matter to calculate the values each time they are needed, but in a large data structure that accesses these values frequently, I want to know if there is a method that calculates the values only once each time the data changes.

Thanks

0

There are 0 best solutions below