• 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
Master "addChildObject:" not called when adding child from an array controller !
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Master "addChildObject:" not called when adding child from an array controller !


  • Subject: Master "addChildObject:" not called when adding child from an array controller !
  • From: Eric Morand <email@hidden>
  • Date: Mon, 28 Sep 2009 00:39:20 +0200

Hi guys,

I'm trying to implement a rather simple functionality in my app.

I have a Core Data entity class that represents invoices (Invoice). This class has a to-many relationship with another Core Data entity class that represents invoice lines (InvoiceLine). My Invoice class also has a property named "totalAmount" and my InvoiceLine class has a property named "lineAmount". I want the total amount of the invoice to be re-computed when any of the invoice lines amount changes.

Searching this list, I found that I need to add the invoice instance as an observer to the lineAmount property of any invoice line added with the "addInvoiceLineObject:" method. It works.
But only when I explicitly use this method. When the invoice line is added using an array controller, the method is not called at all !!!


For example, I have an array controller named "invoicesController" that lists all the invoices of the database. Then I have an array controller named "invoiceLinesController" whose content is bound to "invoicesController.selection.invoiceLines". It works : invoiceLinesController actually contains the invoice inlines of the selected invoice in invoicesController.

Now, when I add a saleLine using the following command...

InvoiceLine * myNewInvoiceLine = [NSEntityDescription insertNewObjectForEntityForName:@"InvoiceLine" inManagedObjectContext:managedObjectContext];
[invoiceLinesController addObject:myNewInvoiceLine];


...the "addInvoiceLineObject:" method of the selected invoice is not called, even if the invoice line is actually added to the invoiceLines mutable set of the invoice !

How am I supposed to add the invoice as an observer of the added invoice line (myNewInvoiceLine) properties ?
Wy is the addInvoiceLineobject: method not called ? Is the array controller inserting the invoice line using primitive methods ? Is this the normal behavior ?



Thanks for your help,


Eric Morand. _______________________________________________

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


  • Follow-Ups:
    • Re: Master "addChildObject:" not called when adding child from an array controller !
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Formatter and error windows (sheet AND modal)
  • Next by Date: Re: Can an app query the values in its own Info.plist?
  • Previous by thread: Formatter and error windows (sheet AND modal)
  • Next by thread: Re: Master "addChildObject:" not called when adding child from an array controller !
  • Index(es):
    • Date
    • Thread