Good night, I have a function that is linked to a button, I would like to call it directly without the need of the button, what do I do?
The function ...
static func goToTutorialOrTo(market: Market, from viewController: UIViewController) {
BusinessesContainer.selectedMarket = market
AnswersHelper.sendAccessMarketTracker()
if UserDefaultManager.didSawTutorial() {
let rootMarketViewController = StoryBoard.rootMarketViewController()
viewController.present(rootMarketViewController, animated: false, completion: nil)
} else {
let tutorialViewController = StoryBoard.main().instantiateViewController(withIdentifier: "tutorial")
viewController.present(tutorialViewController, animated: true, completion: nil)
}
}
The function called by the button ...
extension SupermercadosZonaViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
StoryBoard.goToTutorialOrTo(market: selectedMarketsToShowInTableView[indexPath.row], from: self)
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return StoryBoard.isIpad ? 175 : 110
}
}
My attempt to call it directly
First ...
StoryBoard.goToTutorialOrTo(market: Market.init(json: <#T##JSON#>)!, from: self as! UIViewController)
Second ...
SupermercadosZonaViewController()
In neither case did I succeed.