So I have two objects, Invoice and InvoiceLineItem. InvoiceLineItem has a property called cost and it is dynamically created based on other properties. To help with the KVO/bindings I use:

+ (NSSet *)keyPathsForValuesAffectingCost {
    return [NSSet setWithObjects:@"lineItemType", @"serviceCost", @"hourlyRate", @"timeInSeconds", @"productCost", @"quantityOfProduct", @"mileageCost", @"milesTraveled", nil];
}

This works great. When I edit a property like serivceCost the main cost in the Table View updates fine.

In the Invoice object I have an NSMutableArray of InvoiceLineItems. Invoice has a similar property called totalCost. It is calculated by iterating over the line items and as long as the line item isn't marked as deleted(which I do for syncing reasons) it adds up the costs and creates the totalCost.

Now my question/issue. How do I set up Invoice's totalCost so that it works with KVO/bindings when one of the line item's costs has changed?

I tried setting up:

+ (NSSet *)keyPathsForValuesAffectingTotalCost {
    return [NSSet setWithObjects:@"lineItems.cost", nil];
}

but it doesn't work. I end up with an error in the console: [<NSCFArray 0x1499ff40> addObserver:forKeyPath:options:context:] is not supported. Key path: cost

Edit
Report