Cocoa: Counting the number of related objects using bindings

Discussion in 'Mac Programming' started by MacDonaldsd, Feb 29, 2008.

  1. macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #1
    Hi,

    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.
     

    Attached Files:

  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    I don't know exactly based on your model, but you can try using @count:

    bindings_count.png
     
  3. thread starter macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #3
    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
     

Share This Page