Re: CoreData - calculations in tables?
Re: CoreData - calculations in tables?
- Subject: Re: CoreData - calculations in tables?
- From: Alan Dail <email@hidden>
- Date: Wed, 6 Jul 2005 17:17:42 -0400
Thanks - that works great!
Now I have a related issue. I have another column that sums a field
in the array instead of simply counting the number of items in the
array. The same technique works to calculate the totals, but the
notifications only come on add/delete, they don't come when an array
member is changed - is there a way to do this. For example, suppose
in your example you wanted an averageGrade, how do I set it up so
this will stay current?
thanks,
Alan
On Jul 6, 2005, at 4:14 PM, Charilaos Skiadas wrote:
On Jul 6, 2005, at 2:53 PM, Alan Dail wrote:
ok, I've done some more testing.
the first approach was to add an itemCount method that returns the
current count as suggested in the link. The problem here is, the
display doesn't update immediately when I add/remove items to the
list in the other table. Checking continuously update doesn't
seem to help, and this doesn't seem to be what I'd want to do
anyway. What I want is to simply have the view be notified that
there was a change so it can recompute on an as needed basis.
Did you also add the necessary code in your initiallize method to
trigger the notifications on changes? Something like:
+ (void)initialize {
if (self == [CHSGradesItem class]) {
NSArray *keys = [NSArray arrayWithObject:@"grades"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey:@"totalGrades"];
[self setKeys:keys
triggerChangeNotificationsForDependentKey:@"totalStudents"];
}
}
Sorry I didn't mention this earlier, I thought it was in the link I
mentioned, but I guess it was somewhere else that I saw it. I think
some ADC document, can't remember where.
The basic idea is to get notified when there's a change to a
sublist so the calculation, display (and sorting if appropriate)
will get updated.
Alan
Haris
_______________________________________________
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