I am new to xcode/ios etc… and having a little trouble figuring out a problem. I cant seem to figure out how I would retrieve and perform calculations on attributes between entities in core data. Here is an example of what I am trying to do:
My project is a football app that has a one to many relationship. Season to Game (Season has a bunch of games. Season has attributes like teamname and datestart. Game has attributes like passing yards, running yards etc..
How would I be able to calculate something like total passing yards for the whole season (adding all the games passing yards together for that season)?
Thanks for your time.
You managed object for Season has a relationship named hasGames (or whatever you named the relationship to the games). When you have a Season managed object, you can just access the hasGames relationship (it’s an NSSet), loop through all the games in there and do whatever you want with the data, e.g. adding some values up.
EDIT:
Example:
If I take your Relationships Career -> Season -> Game, and suppose the relationships are called Career.hasSeasons and Season.hasGames, it would look something like this