Re: Core Data question on calculating percentages
Re: Core Data question on calculating percentages
- Subject: Re: Core Data question on calculating percentages
- From: Scott Redheffer <email@hidden>
- Date: Sat, 01 Oct 2005 09:32:33 -0600
- Thread-topic: Core Data question on calculating percentages
Would this be a good or workable solution since I want the values to be
dynamic with any changes?
Have an accessor method that does a fetch of all expenses and then calculate
the percentage using @sum on fetched array and the "Expense Amount".
Then have "Expense Amount" be a triggerForDependantKey for "Percentage of
Total" and also have the Expenses object be an observer of any managed
object context changes and call the accessor method. Is awakeFromFetch the
best place to put the addObserver call and then should you also put a
removeObserver in didTurnIntoFault?
I seems like a waste to make a fetch request for every expense item. Is
there a better way or better data model to use in these types of
situtations.
SPR
on 10/1/05 08:39, John Timmer at email@hidden wrote:
> You should be able to make a fetch of all Expenses, then use the @sum
> operator to get the total. You could either do this on the fly every time
> it's needed, or in the "awakeFromFetch" and have your object observe its
> managed object context for changes that include new entities or modified
> expenses.
>
> JT
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden