title: Swift dismiss modal view on tableView select (best practices for control flow)
body: <p>I am working on a Swift application that needs to set the application scope from a tableView -- the user will select a list item which will then set an ID which controls the data loaded in other views. I am currently opening the tableView as a modal but I am not sure what is the best practice for closing the modal from within the <code>setSelected(selected: Bool, animated: Bool)</code> function call of a custom tableViewCell subclass (or even if dismissing the modal from this function is the best practice). I was considering passing a reference of the parent view that loaded the modal and then using <code>dismissViewControllerAnimate</code> but that is not working.</p>
  
  <p><em>Edit</em> : my original post seemed to be unclear so I will try to clearly ask my questions:</p>
  
  <p>1.) I need dismiss the modal view and the only function I have come across so far is <code>dismissViewControllerAnimate</code> -- is this the function I should be using or are there others for others uses?</p>
  
  <p>2.) If <code>dismissViewControllerAnimate</code> is the correct function, should I be calling it from within the <code>setSelected</code> function of the tableViewCell?</p>
  
  <p>3.) If I should call from within <code>setSelected</code>, should I pass a reference of the ViewController to the tableViewCell so that it can call <code>dismissViewControllerAnimate</code> from <code>setSelected</code>?</p>
  
  <p><em>/Edit</em></p>
  
  <p>Any help or suggestions will be much appreciated!</p>