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

2009-09-28 Thread Eric Morand
Sorry, this is a typo : my method is actually called  
addInvoiceLinesObject:



Le 28 sept. 2009 à 06:03, Kyle Sluder a écrit :


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  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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/kyle.sluder%40gmail.com

This email sent to kyle.slu...@gmail.com




--
--Kyle Sluder


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


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

2009-09-27 Thread Kyle Sluder
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  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 (Cocoa-dev@lists.apple.com)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/kyle.sluder%40gmail.com
>
> This email sent to kyle.slu...@gmail.com
>


-- 
--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


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

2009-09-27 Thread Eric Morand

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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com