Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

WillH16

macrumors newbie
Original poster
Apr 16, 2010
3
0
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:
http://www.e-string.com/content/custom-uitableviewcells-interface-builder

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.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.