8000 Memory leak when setting navigation controller delegate on view controller. · Issue #3 · imaccallum/CoordinatorKit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Apr 11, 2020. It is now read-only.
This repository was archived by the owner on Apr 11, 2020. It is now read-only.
Memory leak when setting navigation controller delegate on view controller. #3
Open
@pavankataria

Description

@pavankataria

Like with all the other examples and yours, setting the view controller as the delegate to the navigation controller delegate property breaks your closure link responsible for deallocating the child coordinator.

To reproduce, replace this code block into the ProfileCoordinator.swift file and toggle on and off the setting of the navigation controller delegate property in the ProfileCoordinator class to see it in action.

class ProfileViewController: UIViewController, UINavigationControllerDelegate {
    deinit {
        print("deinitialised")
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.red
        
        //Toggle this line on and off as a comment to see that this view controller is never deinitialised.
        self.navigationController?.delegate = self
    }
}

class ProfileCoordinator: Coordinator<DeepLink> {
	
	let viewController = ProfileViewController()
	private let store: StoreType
	
	init(router: RouterType, store: StoreType) {
		self.store = store
		super.init(router: router)
	}
	
	// We must override toPresentable() so it doesn't
	// default to the router's navigationController
	override func toPresentable() -> UIViewController {
		return viewController
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0