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 15:53:26 -0400
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.
So my second approach was to simply map the column to the items array
and write a value transformer to calculate the number of items in the
list. This works as I hoped it would - adding/removing items to the
array causes the display to update immediately, no extra updating is
occuring. The one remaining problem I have is I can't sort the table
by number of items. When I click on the column heading, it doesn't
change the sort - i guess it's trying to sort items and not the
transformed value. Is there a way to cause the sorting to happen
based on the transformed values? Is there another approach I should
be using?
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
On Jul 6, 2005, at 2:28 AM, Charilaos Skiadas wrote:
On Jul 6, 2005, at 12:40 AM, Alan Dail wrote:
I am building an app with CoreData and have run into a couple of
issues.
I have a view with two tables, each with their own
NSArrayController. Using bindings, the content set of the 2nd
controller is the selection of the first controller. i.e. the
first table is a list of people, the 2nd list is a list of items
for the selected person. When I select a person, I can add or
delete items for that person. What I wanted to do, though, is add
a column to my table that has the number of items for each
person. The first thing I tried was to simply copy the way the #
out of # display is generated when you create a defeault core data
view - i.e. I mapped a table column to items.@count - this
actually displays the item count for each person, but does not
update when items are added or removed and caused all sorts of
problems if i added items to the main list as a result of
notifications.
What sorts of problems? I usually find useful answers to such
problems by googling for the exception that was thrown in the console.
As a possible solution, maybe you could set the "Continuously
updated value" checkbox at the right place?
How should I be doing things like this. In addition to a simple
total, I'd also like to be able to do other calculations on items
in the list. For instance, if they have an attribute that is a
number, I'd like to be able to have the main list give a total
amount from summing all of the items in the sublist.
I think this came up in the past, I had a very similar problem
yesterday. I think this might answer your question, it did in my case:
http://www.cocoabuilder.com/archive/message/2005/5/18/136314
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