totals
totals
- Subject: totals
- From: Keith Penrod <email@hidden>
- Date: Wed, 23 Jan 2008 16:26:52 -0500
So, I have two kinds of entities: a Category and an Item. Category
has a to-many relationship to the Item class, and the inverse relation
also exists. I'm displaying the Categories in one table and the Items
that belong to the selected category in another table. Each item has
a float attribute and I'd like for one of the columns in the category
table to display the sum of all of those floats. I'd also like to
have a grand total, which sums up all the totals for the various
categories. I know how to do all of this stuff, but I'm having
trouble making it update the totals as the user modifies the Items.
I tried having the NSTextFieldCell send its action to the
NSArrayController that contains all the Categories, but that didn't
seem to work--it wouldn't send the action when I edited the cell.
Then I tried using NSNotificationCenter and adding each category as an
observer to each of its items as the items are created. However, this
only works on the Items that exist at the time of loading the app--it
doesn't work for items newly created while the app is still running,
and I believe that's because that at the time I add the category as an
observer, the pointer is nil. I'm trying to do it in the
initWithEntity method, but apparently at the time that method is
called (even after [super initWithEntity...]) the category pointer is
nil.
What method would be best for setting up the automatic updating?
Keith
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden