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

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


  • Subject: Re: Master "addChildObject:" not called when adding child from an array controller !
  • From: Kyle Sluder <email@hidden>
  • Date: Sun, 27 Sep 2009 21:03:08 -0700

You named the method -addInvoiceLineObject:, but the property is
-invoiceLines?  That's not going to work.

Also, NSController is sadly not KVO-compliant for dependent keys,
meaning that you can't override
+keyPathsForValuesAffectingValueForKey: and return a key path that
goes through an NSController.

--Kyle Sluder

On 9/27/09, Eric Morand <email@hidden> wrote:
> 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
>


--
--Kyle Sluder
_______________________________________________

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: Eric Morand <email@hidden>
References: 
 >Master "addChildObject:" not called when adding child from an array controller ! (From: Eric Morand <email@hidden>)

  • Prev by Date: how do i make SecKeyRef object from NSData of publicKey value
  • Next by Date: Re: Can an app query the values in its own Info.plist?
  • Previous by thread: Master "addChildObject:" not called when adding child from an array controller !
  • Next by thread: Re: Master "addChildObject:" not called when adding child from an array controller !
  • Index(es):
    • Date
    • Thread