Fetching child sum from Core Data
问题 Lets say I have three Entitys. Person: name address (to-many-salary) and (to-many-loans) Salary: income tax Rel: (to-one-Person) Bills amount Rel: (to-one-person) How do I perform a fetch that have a result like this: John Doe, SUM>income, SUM>amount Eva Doe, SUM>income, SUM>amount Using Swift 回答1: This is probably most easily done using Key Value Coding "collection operators" (see here) rather than a fetch. For each person : let name = person.name let totalIncome = person.valueForKeyPath(