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 setSelected(selected: Bool, animated: Bool)
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 dismissViewControllerAnimate
but that is not working.
Edit : my original post seemed to be unclear so I will try to clearly ask my questions:
1.) I need dismiss the modal view and the only function I have come across so far is dismissViewControllerAnimate
-- is this the function I should be using or are there others for others uses?
2.) If dismissViewControllerAnimate
is the correct function, should I be calling it from within the setSelected
function of the tableViewCell?
3.) If I should call from within setSelected
, should I pass a reference of the ViewController to the tableViewCell so that it can call dismissViewControllerAnimate
from setSelected
?
/Edit
Any help or suggestions will be much appreciated!