This should work:
- (NSDecimalNumber *)totalAssetValue
{
return [self valueForKeyPath:@"accounts.@sum.assets.@sum.assetAmount"];
}
Both "accounts" and "assets" are to-many relationships, therefore you need two "@sum" operators (corresponding to the two nested for-loops in your original code).
Note that it not officially documented (as far as I know) that the Key-Value Coding "@sum"
operator returns an NSDecimalNumber
, it might be "just" an NSNumber
.