Doing calculations in UITableViewCells

Discussion in 'iOS Programming' started by WillH16, May 18, 2010.

  1. WillH16 macrumors newbie

    Apr 16, 2010
    Hey guys, I'm trying to create an application which displays a grid of buttons that the user can press into to modify its title and save it into an underlying data model. To do this, I created a custom UITableViewCell and loaded into a table view, as I felt this was simpler than manually building out every single button in the application. I used the following tutorial:

    My question is, where would I implement the IBAction methods that will allow me to actually manipulate the buttons and data?

    I tried to set the file's owner in the custom cell's nib file to the same view controller that's displaying the table view, but when I hook up an IBAction that way, it causes the app to crash without any messages. When I create the IBAction method in the custom cell's implementation file, it seems to work fine. But this means that I will have to pass the managedObjectContext into it in order to manipulate the underlying data. Is this correct?

    Thanks in advance.
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    You should be able to do this in any of the ways that you mention.

    Connecting a button in a cell to an action method in its file's owner should work.

    Connection a button in a cell to an action method in the custom cell should also work. You can either pass the info about the data model to the cell or you can have a delegate method that calls the view controller when the value changes.

    I would usually prefer to have the cell just display info and have the view controller manage setting this info from the data model or updating the value in the data model when the cell changes.

Share This Page