Skip to content

Instantly share code, notes, and snippets.

@Yeltsinn
Yeltsinn / URLSession-automatic-cookie-handling.swift
Last active October 13, 2024 16:51
Automatic handling of cookies in URLSession
class MyViewController: UIViewController {
private var associatedView = MyView()
override func loadView() {
self.view = associatedView
}
override func viewDidLoad() {
associatedView.someLabel?.text = "my string value"
class MyViewController: BaseViewCodeController<MyView> {
override func viewDidLoad() {
associatedView?.someLabel?.text = "my string value"
}
}
/* ViewCode protocol */
protocol ViewCodable {
func buildHierarchy()
func setupConstraints()
func setupConfigurations()
}
extension ViewCodable {
func setupView() {
buildHierarchy()
class BaseViewController<View>: UIViewController where View: UIView {
var associatedView: View? { return self.view as? View }
override func loadView() {
super.loadView()
self.view = View()
}
}