• 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: KVO / Core Data question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVO / Core Data question


  • Subject: Re: KVO / Core Data question
  • From: Diederik Hoogenboom <email@hidden>
  • Date: Wed, 14 Dec 2005 21:00:02 +0100

Paul,

Maybe you can use a fetched property for this. I seem to remember that you can also use "sum()" as an expression.

Regards,

Diederik

On 14-dec-2005, at 17:49, Paul L. Gribble wrote:

I have an entity "Trip" that has a to-many relationship to another entity,
"Transaction" via a relationship called "transaction".

The Trip entity has a key called "balance" whose value I want to depend on
the sum of all of the "amount" keys of each transaction.

I understand from reading Apple's Core Data FAQ (pg. 108-109) that it's not
possible to do this using setKeys:triggerChangeNotificationsForDependentKey,
where the key would be a key-path (e.g. email@hiddent).

The FAQ suggests two solutions - one, use KVO to register the parent as an
observer of the relevant attribute of all the children; and one must then
add and remove the parent as an observer, each time child objects are added
to or removed from the relationship. This seems not very efficient compared
to the second suggestion:

register the parent with the application's notification center as an
observer of its managed object context. This seems like less coding to me,
but there are no examples. Can anyone provide, or point me to, a code
snippet showing how one would do this?

Thanks,


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40hoogenboom.be

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
References: 
 >KVO / Core Data question (From: "Paul L. Gribble" <email@hidden>)

  • Prev by Date: Re: Background helper tool location change problem
  • Next by Date: Re: Build tool
  • Previous by thread: Re: KVO / Core Data question
  • Next by thread: Re: KVO / Core Data question
  • Index(es):
    • Date
    • Thread