I'm calling my presenter functon that is listed in a protocol that my presenter is implementing but whenever i call it it never goes inside, how do i initilize my presenter so i can call the interface funcion ?
here is my view controller:
import UIKit
class FirstScreenViewController: UIViewController, MainViewProtocol {
var myPresenter: MainPresenterProtocol?
func outputPresenterFunction() {
print (myPresenter?.presenterProtocolFuncTwo(numOne: 2, numTwo: 4, sucssesMessage: "Made it ?", failMessage: "failed :(" ) ?? "Default landed")
}
}
in my presenter i have:
import Foundation
class MainPresenter: MainPresenterProtocol {
var screenViewController: MainViewProtocol?
func presenterProtocolFuncTwo(numOne: Int, numTwo: Int, sucssesMessage: String, failMessage: String) -> String {
print("function is called")
return "presenter function is called sussfuly"
}
}
and my protocol itself:
protocol MainViewProtocol {
func showSmallHeadline(textToShow: String)
func showHeadline(textToShow: String)
}
protocol MainPresenterProtocol {
static func presenterProtocolFuncOne()
func presenterProtocolFuncTwo(numOne: Int, numTwo: Int, sucssesMessage: String, failMessage: String) -> String
func presenterProtocolFucThree () -> Bool
}
whenever i call the presenterProtocolFuncTwo, i get my default value and it doens't go inside the function in my presenter
You should
myPresenter
andscreenViewController
properties to work with them.You need assign an object to your property
myPresenter
somewhere in your code, like in viewDidLoad for example