Core Data: how to sum numbers in NSTableView

Discussion in 'Mac Programming' started by sebastijan, May 5, 2007.

  1. sebastijan macrumors member

    Joined:
    May 22, 2005
    Location:
    London, UK
    #1
    Hi. I have one question about Cocoa and Core Data.

    How can I sum numbers in NSTableView and show them in NSTextField (and update any changes)? Like in this pic:

    [​IMG]
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    You are thinking about it the wrong way. You don't sum the numbers held in a view: views don't store numbers. You need to setup the controller layer to sum the data held in the model.

    Assuming you are using bindings then you simply need to bind the content of the text field to the controller providing the data for the table using @sum.

    This example shows how to do it with @count...
     
  3. sebastijan thread starter macrumors member

    Joined:
    May 22, 2005
    Location:
    London, UK

Share This Page