Re: CoreData - calculations in tables?
Re: CoreData - calculations in tables?
- Subject: Re: CoreData - calculations in tables?
- From: Todd Blanchard <email@hidden>
- Date: Wed, 06 Jul 2005 19:06:35 -0600
(resent with correct subject - sorry)
I've been working on a binding between CLIPS (http://www.ghg.net/clips/CLIPS.html) and ObjectiveC/CoreData. CLIPS is an expert system shell written in C that lets you write rules with actions that are triggered when certain data patterns are detected in your object model. I've created a binding between CLIPS and FScript to provide more power and access to the ObjectiveC model. It is proving to be very powerful.
You can write a simple rule like this:
(defrule maintain-project-min-start-date "Make sure that any task start date is the same as its earliest subtask start"
?subtask<-(Task (parentTask ?parent&~nil) (startTime ?substart&~nil)) "match any task with a non-nil parent and non-nil startTime"
?task<-(Task (self ?parent) (startTime ~?substart)) "match it's parent"
(not(Task (parentTask ?parent) (startTime ?earlier&~nil&:([?earlier < ?substart])))) "match the non-existence of an earlier sibling"
=>
([?task setValue: ?substart forKey: 'startTime'])) "set the value of the startTime on the parent to the startTime on the earliest child"
The bits in [] are FScript blocks. They can be used for actions or predicates as you see above.
I have written a reasonably complex project management application without writing a single line of Objective C using only CLIPS rules, FScript action blocks, CoreData for modeling the data, and IB bindings.
I'll be releasing the framework later this summer once I get it cleaned up and finish my app (the app is driving the framework as you might guess). If you'd like some info or want to play with what I have, email me and tell me about your project.
-Todd Blanchard
On Jul 5, 2005, at 10:40 PM, 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.
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.
_______________________________________________
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
_______________________________________________
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