title: How to Present a viewcontroller from a UItableviewcell
body: <p>I am trying to follow the MVC model in developing my iOS app and have an issue here: how do I fire a viewcontroller from a tableviewcell, instead of its parent tableviewcontroller. PresentViewController can only be invoked from a viewcontroller. </p>
  
  <p>Here is the situation:</p>
  
  <ul>
  <li><p>I have a data object at the backend myDataObject;</p></li>
  <li><p>I also have a tableview where I populated a type of table view cell, myDataCell, with an instance of MyDataObject;</p></li>
  <li><p>Now, I would like to programmatically (instead of segue) trigger another ViewController from a UIButton click event in myDataCell.</p></li>
  </ul>
  
  <p>My goal is to decouple the MVC as much as possible, by trying to avoid having each object keeping pointers to the other two involved, for example, I do not want the cell to keep reference of MyDataObject, nor do I want it to keep reference of its tableviewcontroller. </p>
  
  <p>Here are several scenarios of how to handle this situation, and the challenges:</p>
  
  <ol>
  <li>declare myDataCellDelegate and myDataObjectDelegate, implement methods from both delegate declarations in the tableviewcontroller, and set a reference of the tableviewcontroller and myDataCell in the delegate. This way myDataObject has a reference to the tableviewcontroller and myDataCell. </li>
  </ol>
  
  <p>Question here is how do I invoke handleButtonTouched event from myDataCell, and still be able to present the next viewcontroller, without accessing myDataObject from myDataCell? Or do I have to keep a reference of myDataObject in myDataCell? I already have a reference of myDataCell in myDataObject from the delegate method above. </p>
  
  <ol start="2">
  <li>declare myDataObjectDelegate only, and implement the delegate methods in the tableviewcontroller. I can set the reference of the tableviewcontroller and myDataCell in the delegate. This way myDataCell does not have to have reference to its parent viewcontroller, only myDataObject has reference to both.</li>
  </ol>
  
  <p>With this approach, I can do myDataObject->tableviewcontroller->presentviewcontroller. But how do I make the myDataCell->buttonclick event as the trigger? I still need to pass the info from myDataObject to myDataCell.</p>
  
  <p>Thanks guys. </p>
  
  <p>EDIT:</p>
  
  <p>I forgot to mention that my goal of going through such trouble is that I intend to keep myDataCell and myDataObject in a framework.</p>