View Full Version : Cocoa: Counting the number of related objects using bindings

Feb 29, 2008, 08:29 AM

I have a feeling this is a rather dumb question but I can't seem to find the answer.

Im trying to achieve something that can be seen in Journler, whereby I wish to count the number of attachments for a given event using bindings.

Im using core data and I have and Event class that has a relationship with the document class.

I realise I can solve this using a value transformer, but if its possible using bindings that would be easier.

Feb 29, 2008, 10:56 AM
I don't know exactly based on your model, but you can try using @count (http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/ArrayOperators.html#//apple_ref/doc/uid/20002176-184206):


Feb 29, 2008, 02:41 PM
Hi thanks for the link it was very helpful, I didn't realise you can prefix the @count with an attribute.

I used documents.@count for the model key path and that does the trick