Re: Core data model, bindings advice.
Re: Core data model, bindings advice.
- Subject: Re: Core data model, bindings advice.
- From: Steven Huey <email@hidden>
- Date: Mon, 12 May 2008 10:27:17 -0400
Steven,
In my app I have a similar setup, although without the detail view.
I have the Table Column of my NSOutlineView bound to a
NSTreeController using the Controller Key "arrangedObjects" and the
Model Key Path set to the name of a method in the custom
NSManagedObject subclass that my NSTreeController is managing.
The table columns of my NSTableView are bound to an NSArrayController
whose content set is bound to my NSTreeController's selection. Each
column is then bound to a property of the entity returned by the array
controller's content.
I think you could bind your detail view similarly, to the current
selection of your array controller.
Take a look at: http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
for lots of great examples of how to use bindings.
Best regards,
Steven Huey
--
Steven Huey Software - http://www.stevenhuey.com
On May 12, 2008, at 8:03 AM, Steven Hamilton wrote:
Hi folks,
Continuing my learning into Cocoa I'm developing a personal finance
application. An admirable project I believe since none available
suit my purposes and it always pays to have a project that one would
use to learn from.
I have a simple core data model consisting of AccountGroup, Account,
Transaction and I've jammied these all into a window with outline
view, transaction tableview and detail at the bottom. The model
looks like this;
AccountGroup (Asset, expense, income etc)name (string)
accounts (relationship to Account)Account (Bank, Savings etc)name
(string)
transactions (fetched properties explained below)
credit (relationship to transaction)
debit (relationship to transaction)Transaction
memo (string)
date (date)
amount (NSNumber)
fromAccount (reverse of debit)
toAccount (reverse of credit)
I believe this to be the true model as a transaction is an object
and is of an amount that goes from somewhere to somewhere. This is
double entry accounting. My problem is in presenting this to the user.
Problem 1
Most finance apps, and mine included you select an account from a
list (my outlineview) and it then displays all the transactions
involved. So I created a fetched property with a predicate that
included any transactions that had the selected account name in
either fromAccount or toAccount. This works to a point. My tableview
displays all the transactions of the selected account but since its
a fetched properties (contentArray) the list isn't the true
transaction array (contentSet), therefore I cannot add to it using
the bound detail table below it.
I must admit the bindings for this are really playing with my head.
I struggled quite immensely getting the selection from the
treecontroller and in the end it started working without me fully
understanding why. I have further complications to come as I have
the decide whether the transaction amount is a debit or credit
(based on the from/to account relationships) and then display the
amount in the correct column and then also work out a way to add
transactions back in like this.
It seems even though I'm set on what I believe to be the correct
data model for this, the method of which a user expects to see this
information is a little too different. Does anyone have any advice?
Have I talked too much?
_______________________________________________
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
_______________________________________________
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