• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Binding Dependencies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding Dependencies


  • Subject: Re: Binding Dependencies
  • From: Brian Webster <email@hidden>
  • Date: Sun, 16 Nov 2003 12:40:07 -0600

I don't believe that the trigger will accept full key paths, only simple keys (the docs don't say explicitly, but if key paths were allowed, I think the method would be named setKeyPaths:... instead). So, I think you may have to update the balance manually, by observing the "amount" key on each transaction in the account by calling addObserver:forKeyPath:options:context:

On Nov 16, 2003, at 11:51 AM, Jorge Ramirez wrote:

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.


--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.

References: 
 >Binding Dependencies (From: Jorge Ramirez <email@hidden>)

  • Prev by Date: Is there an Exposé event sent to an NSWindow=3 F??
  • Next by Date: Re: NSTextField getting input number by number
  • Previous by thread: Binding Dependencies
  • Next by thread: Is there an Exposé event sent to an NSWindow=3 F??
  • Index(es):
    • Date
    • Thread