• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CoreData - calculations in tables?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • KVO for derived attributes (was Re: CoreData - calculations in tables?)
      • From: mmalcolm crawford <email@hidden>
References: 
 >CoreData - calculations in tables? (From: Alan Dail <email@hidden>)
 >Re: CoreData - calculations in tables? (From: Charilaos Skiadas <email@hidden>)
 >Re: CoreData - calculations in tables? (From: Alan Dail <email@hidden>)
 >Re: CoreData - calculations in tables? (From: Charilaos Skiadas <email@hidden>)

  • Prev by Date: Simulate Photoshop's "Overlay" compositing method
  • Next by Date: KVO for derived attributes (was Re: CoreData - calculations in tables?)
  • Previous by thread: Re: CoreData - calculations in tables?
  • Next by thread: KVO for derived attributes (was Re: CoreData - calculations in tables?)
  • Index(es):
    • Date
    • Thread