Binding Dependencies
Binding Dependencies
- Subject: Binding Dependencies
- From: Jorge Ramirez <email@hidden>
- Date: Sun, 16 Nov 2003 12:51:02 -0500
I have a question regarding the
"setKeys:triggerNotificationsForDependentKey:" method. I am creating a
very litmited accounting program while I learn about binding and the
NSController class. I have the following classes with the given
attributes...
Account Class
float openingBalance;
NSString *name;
NSMutableArray *transactions;
Transaction Class
float amount;
NSString *payee;
NSDate *date;
NSString *category;
BOOL cleared;
My question is the following, I have a "balance" method in the account
class which sums the transaction amounts using the @sum operator.
Since the balance depends on the transactions and their amounts, i
would like to use the "setKeys:triggerNotificationsForDependentKey:"
method to recalculate the balance everytime an amount is changed or a
transaction is added. I have tried putting the following in the
"+initialize" method of the account class...
[self setKeys:[NSArray arrayWithObjects:@"transactions.amount", nil]
triggerChangeNotificationsForDependentKey:@"balance"];
but this is not working. when i change a transaction amount, the
balance does not get changed. I have also tried just "transactions"
for the key. How should i set the key for the dependency?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.