I have to set up a project that has to contain several targets. The goal is to have a code base to share it with all the targets that will be created later. I make an example : I will have a UIViewController for the login, but this will be different for every target. My idea is to have a code base to share with every specific LoginViewController . What is the best approach to structure the code? I started writing a protocol, here it is :

protocol LoginProtocol { weak var txtUsername: UITextField? { get set } weak var txtPassword: UITextField? { get set } weak var btnLogin: UIButton? { get set } func login() }

The idea is to implement this protocol in every controller.

The other approach is to write a sort of base view controller that every other controller will inherit from. Like this :

// MARK: - Instance vars and IBOutlets class LoginViewController: UIViewController { @IBOutlet weak var txtUsername: UITextField? @IBOutlet weak var txtPassword: UITextField? @IBOutlet weak var btnLogin: UIButton? override func viewDidLoad() { super.viewDidLoad() } } extension LoginViewController { func login() { print("Hello") } }

What do you think? What is the best choice, architecturally?